Class: OpenAPIRest::Validators::Pattern
- Inherits:
-
Object
- Object
- OpenAPIRest::Validators::Pattern
- Defined in:
- lib/openapi_rest/validators/pattern.rb
Overview
Rest pattern validator
Instance Method Summary collapse
- #error(key) ⇒ Object
-
#initialize(format, value) ⇒ Pattern
constructor
A new instance of Pattern.
- #valid? ⇒ Boolean
Constructor Details
#initialize(format, value) ⇒ Pattern
Returns a new instance of Pattern.
7 8 9 10 |
# File 'lib/openapi_rest/validators/pattern.rb', line 7 def initialize(format, value) @format = format @value = value end |
Instance Method Details
#error(key) ⇒ Object
16 17 18 |
# File 'lib/openapi_rest/validators/pattern.rb', line 16 def error(key) { key => "invalid format #{@format}" } end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/openapi_rest/validators/pattern.rb', line 12 def valid? Regexp.new(@format).match(@value) end |