fluke/devops-service/db/validators/field_validators/name.rb

19 lines
433 B
Ruby
Raw Normal View History

require_relative "base"
module Validators
module FieldValidator
class Name < Base
MAX_NAME_LEN = 200
NAME_REGEX = /\A\w{1,#{MAX_NAME_LEN}}\z/
def valid?
!NAME_REGEX.match(@value).nil?
end
def message
2015-11-02 17:33:25 +03:00
"Invalid value '#{@value}': it should contains symbols 'a-zA-Z0-9_' and length should be more then 1 and less or equals then #{MAX_NAME_LEN} symbols"
end
end
end
end