Class: Katello::Apipie::Validators::IdentifierValidator

Inherits:
Apipie::Validator::BaseValidator
  • Object
show all
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



58
59
60
61
62
# File 'lib/katello/apipie/validators.rb', line 58

def self.build(param_description, argument, _options, _block)
  if argument == :identifier
    self.new(param_description)
  end
end

Instance Method Details

#descriptionObject



68
69
70
# File 'lib/katello/apipie/validators.rb', line 68

def description
  "string from 2 to 128 characters containing only alphanumeric characters, space, '_', '-' with no leading or trailing space.."
end

#errorObject



64
65
66
# File 'lib/katello/apipie/validators.rb', line 64

def error
  "Parameter #{param_name} expecting to be an identifier, got: #{@error_value}"
end

#validate(value) ⇒ Object



53
54
55
56
# File 'lib/katello/apipie/validators.rb', line 53

def validate(value)
  value = value.to_s
  value =~ /\A[\w| |_|-]*\Z/ && value.strip == value && (2..128).include?(value.length)
end