Class: Leftovers::ConfigLoader::RegexpSchema
- Inherits:
-
StringSchema
- Object
- Schema
- StringSchema
- Leftovers::ConfigLoader::RegexpSchema
- Defined in:
- lib/leftovers/config_loader/regexp_schema.rb
Class Method Summary collapse
Methods inherited from Schema
Class Method Details
.validate(node) ⇒ Object
7 8 9 |
# File 'lib/leftovers/config_loader/regexp_schema.rb', line 7 def validate(node) validate_string(node) && validate_regexp(node) end |
.validate_regexp(node) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/leftovers/config_loader/regexp_schema.rb', line 17 def validate_regexp(node) /#{node.to_ruby}/ rescue ::RegexpError, ::ArgumentError => e error(node, "be a string with a valid ruby regexp (#{e.})") else true end |
.validate_string(node) ⇒ Object
11 12 13 14 15 |
# File 'lib/leftovers/config_loader/regexp_schema.rb', line 11 def validate_string(node) error(node, 'be a string with a valid ruby regexp') unless node.string? node.valid? end |