fluke/devops-service/db/validators/field_validators/image_username.rb
2016-01-27 16:44:59 +04:00

19 lines
442 B
Ruby

require_relative "base"
module Validators
module FieldValidator
class ImageUsername < Base
MAX_NAME_LEN = 100
NAME_REGEX = /\A[\w\-\.]{1,#{MAX_NAME_LEN}}\z/
def valid?
!NAME_REGEX.match(@value).nil?
end
def message
"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}"
end
end
end
end