Class: OpenAPIRest::Validators::Format
- Inherits:
-
Object
- Object
- OpenAPIRest::Validators::Format
- Defined in:
- lib/openapi_rest/validators/format.rb
Overview
Rest format validator
Instance Method Summary collapse
- #error(key) ⇒ Object
-
#initialize(format, value) ⇒ Format
constructor
A new instance of Format.
- #valid? ⇒ Boolean
Constructor Details
#initialize(format, value) ⇒ Format
Returns a new instance of Format.
7 8 9 10 |
# File 'lib/openapi_rest/validators/format.rb', line 7 def initialize(format, value) @format = format @value = value end |
Instance Method Details
#error(key) ⇒ Object
19 20 21 |
# File 'lib/openapi_rest/validators/format.rb', line 19 def error(key) { key => "not a #{@format}" } end |
#valid? ⇒ Boolean
12 13 14 15 16 17 |
# File 'lib/openapi_rest/validators/format.rb', line 12 def valid? return @value.is_a?(Numeric) if @format == 'int64' || @format == 'int32' return !DateTimeHelper.in_utc(@value).nil? if @format == 'date-time' true end |