Class: OpenActive::Validators::TimeValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- OpenActive::Validators::TimeValidator
- Defined in:
- lib/openactive/validators/time_validator.rb
Overview
schema.org/Time format spec: www.w3.org/TR/xmlschema-2/#time
Constant Summary collapse
- REGEX =
www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch04s07.html#id2175516 Minor additions to make second values and timezone optional
/(?<hour>2[0-3]|[01][0-9]):?(?<minute>[0-5][0-9]):?(?<second>[0-5][0-9])?(?<timezone>Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?)?/.freeze
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.
16 17 18 |
# File 'lib/openactive/validators/time_validator.rb', line 16 def coerce(value) value end |
#run(value) ⇒ Boolean
Run validation on the given value.
24 25 26 |
# File 'lib/openactive/validators/time_validator.rb', line 24 def run(value) REGEX =~ value end |