Class: OpenActive::Validators::UriValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- OpenActive::Validators::UriValidator
- Defined in:
- lib/openactive/validators/uri_validator.rb
Instance Method Summary collapse
-
#coerce(value) ⇒ mixed
Coerce given value to the type the validator is validating against.
-
#run(value) ⇒ Boolean
Run validation on the given value.
Methods inherited from BaseValidator
Instance Method Details
#coerce(value) ⇒ mixed
Coerce given value to the type the validator is validating against. PLEASE NOTE: no checks are performed on the given value. It is therefore recommended to call the “run” method first before this.
10 11 12 13 14 |
# File 'lib/openactive/validators/uri_validator.rb', line 10 def coerce(value) return value if value.is_a?(::URI) URI.parse(value) end |
#run(value) ⇒ Boolean
Run validation on the given value.
20 21 22 23 24 |
# File 'lib/openactive/validators/uri_validator.rb', line 20 def run(value) return true if value.is_a?(::URI) value =~ ::URI::DEFAULT_PARSER.make_regexp end |