Class: Apipie::Validator::RegexpValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- Apipie::Validator::RegexpValidator
- Defined in:
- lib/apipie/validator.rb
Overview
validate arguments value with regular expression
Instance Attribute Summary
Attributes inherited from BaseValidator
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(param_description, argument) ⇒ RegexpValidator
constructor
A new instance of RegexpValidator.
- #validate(value) ⇒ Object
Methods inherited from BaseValidator
#error, #expected_type, find, inherited, #merge_with, #param_name, #params_ordered, #to_json, #to_s, #valid?
Constructor Details
#initialize(param_description, argument) ⇒ RegexpValidator
Returns a new instance of RegexpValidator.
118 119 120 121 |
# File 'lib/apipie/validator.rb', line 118 def initialize(param_description, argument) super(param_description) @regexp = argument end |
Class Method Details
.build(param_description, argument, options, proc) ⇒ Object
127 128 129 |
# File 'lib/apipie/validator.rb', line 127 def self.build(param_description, argument, , proc) self.new(param_description, argument) if argument.is_a? Regexp end |
Instance Method Details
#description ⇒ Object
131 132 133 |
# File 'lib/apipie/validator.rb', line 131 def description "Must match regular expression /#{@regexp.source}/." end |
#validate(value) ⇒ Object
123 124 125 |
# File 'lib/apipie/validator.rb', line 123 def validate(value) value =~ @regexp end |