Class: Apipie::Params::Descriptor::Regexp
- Inherits:
-
JsonSchema
- Object
- Base
- JsonSchema
- Apipie::Params::Descriptor::Regexp
- Defined in:
- lib/apipie/params/descriptor.rb
Overview
validate arguments value with regular expression
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(regexp, options) ⇒ Regexp
constructor
A new instance of Regexp.
- #json_schema ⇒ Object
Methods inherited from JsonSchema
Methods inherited from Base
find, inherited, #invalid_param_error, #to_json
Constructor Details
#initialize(regexp, options) ⇒ Regexp
Returns a new instance of Regexp.
133 134 135 136 |
# File 'lib/apipie/params/descriptor.rb', line 133 def initialize(regexp, ) super() @regexp = regexp end |
Class Method Details
.build(regexp, options, block) ⇒ Object
129 130 131 |
# File 'lib/apipie/params/descriptor.rb', line 129 def self.build(regexp, , block) self.new(regexp, ) if regexp.is_a? ::Regexp end |
Instance Method Details
#description ⇒ Object
138 139 140 |
# File 'lib/apipie/params/descriptor.rb', line 138 def description "Must match regular expression /#{@regexp.source}/." end |
#json_schema ⇒ Object
142 143 144 |
# File 'lib/apipie/params/descriptor.rb', line 142 def json_schema super.merge('type' => 'string', 'pattern' => @regexp.source) end |