class AWS::Record::FormatValidator

@private

Constants

ACCEPTED_OPTIONS

Public Instance Methods

message() click to toggle source
# File lib/aws/record/validators/format.rb, line 50
def message
  options[:message] || 'is invalid'
end
setup(record_class) click to toggle source
# File lib/aws/record/validators/format.rb, line 27
def setup record_class
  ensure_type(Regexp, :with, :without)
  ensure_at_least_one(:with, :without)
end
validate_attribute(record, attribute_name, value_or_values) click to toggle source
# File lib/aws/record/validators/format.rb, line 32
def validate_attribute record, attribute_name, value_or_values
  each_value(value_or_values) do |value|

    if options[:with]
      unless value.to_s =~ options[:with]
        record.errors.add(attribute_name, message)
      end
    end

    if options[:without]
      unless value.to_s !~ options[:without]
        record.errors.add(attribute_name, message)
      end
    end

  end
end