Class: Katello::Apipie::Validators::IdentifierValidator
- Inherits:
-
Apipie::Validator::BaseValidator
- Object
- Apipie::Validator::BaseValidator
- Katello::Apipie::Validators::IdentifierValidator
- Defined in:
- lib/katello/apipie/validators.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(param_description, argument, _options, _block) ⇒ Object
22 23 24 25 26 |
# File 'lib/katello/apipie/validators.rb', line 22 def self.build(param_description, argument, , _block) if argument == :identifier self.new(param_description) end end |
Instance Method Details
#description ⇒ Object
32 33 34 |
# File 'lib/katello/apipie/validators.rb', line 32 def description "string from 2 to 128 characters containing only alphanumeric characters, space, '_', '-' with no leading or trailing space.." end |
#error ⇒ Object
28 29 30 |
# File 'lib/katello/apipie/validators.rb', line 28 def error "Parameter #{param_name} expecting to be an identifier, got: #{@error_value}" end |
#validate(value) ⇒ Object
17 18 19 20 |
# File 'lib/katello/apipie/validators.rb', line 17 def validate(value) value = value.to_s value =~ /\A[\w| |_|-]*\Z/ && value.strip == value && (2..128).include?(value.length) end |