Sha256: af442dfe2a5c2851f3d80cb36e27c6e7de2fd8be507e096dae6219c1bb42451b
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# -*- encoding: utf-8 -*- require 'data_mapper/validation/rule/length' module DataMapper module Validation class Rule module Length class Maximum < Rule include Length attr_reader :expected def initialize(attribute_name, options) super @expected = options.fetch(:maximum) end def violation_type(resource) :too_long end def violation_data(resource) [ [ :maximum, expected ] ] end private # Validate the maximum expected value length # # @param [Integer] length # the value length # # @return [String, NilClass] # the error message if invalid, nil if valid # # @api private def valid_length?(length) expected >= length end end # class Maximum end # module Length end # class Rule end # module Validation end # module DataMapper
Version data entries
3 entries across 3 versions & 1 rubygems