# File ValidForm.rb, line 841
        def initialize(field,errorType)
                rs = field.validationRules
                case errorType
                        when LENGTH_TOO_SMALL     then @msg = "%label% must be at least #{rs[:minlength]} characters. (It is only #{field.value.length}.)"
                        when LENGTH_TOO_LARGE     then @msg = "%label% may not be more than #{rs[:maxlength]} characters. (It is currently #{field.value.length}.)"
                        when VALUE_TOO_SMALL      then @msg = "%label% can't be less than #{rs[:minvalue]}."
                        when VALUE_TOO_LARGE      then @msg = "%label% can't be more than #{rs[:maxvalue]}."
                        when DATETIME_TOO_SMALL
                                case rs[:type]
                                        when :date        then @msg = "%label% can't be before #{rs[:minvalue].custom_format('#M#/#D#/#YYYY#')}."
                                        when :time        then @msg = "%label% can't be before #{rs[:minvalue].custom_format('#h#:#mm#:#ss##ampm#')}."
                                        when :datetime    then @msg = "%label% can't be before #{rs[:minvalue].custom_format('#M#/#D#/#YYYY# #h#:#mm#:#ss##ampm#')}."
                                end
                        when DATETIME_TOO_LARGE
                                case rs[:type]
                                        when :date           then @msg = "%label% can't be after #{rs[:maxvalue].custom_format('#M#/#D#/#YYYY#')}."
                                        when :time           then @msg = "%label% can't be after #{rs[:maxvalue].custom_format('#h#:#mm#:#ss##ampm#')}."
                                        when :datetime    then @msg = "%label% can't be after #{rs[:maxvalue].custom_format('#M#/#D#/#YYYY# #h#:#mm#:#ss##ampm#')}."
                                end

                        when TOO_FEW_CHOSEN       then @msg = "Please choose at least #{rs[:minchosen]} option#{rs[:minchosen]!=1 ? 's' : ''} for %label%."
                        when TOO_MANY_CHOSEN      then @msg = "Please choose no more than #{rs[:maxchosen]} option#{rs[:maxchosen]!=1 ? 's' : ''} for %label%."

                        when REQUIRED_VALUE_EMPTY then @msg = rs[:reqfail_msg]  || "%label% is a required field."
                        when MATCH_FAIL_PHONE     then @msg = rs[:typefail_msg] || "%label% does not look like a valid phone number.\nIt should be like: (123) 456-7890 or 123.456.7890"
                        when MATCH_FAIL_EMAIL     then @msg = rs[:typefail_msg] || "%label% does not look like a valid email address.\nIt should be like: john@somehost.com"
                        when MATCH_FAIL_ZIPCODE   then @msg = rs[:typefail_msg] || "%label% does not look like a valid zip code.\nIt should be like: 19009 or 19009-0723"
                        when MATCH_FAIL_INTEGER   then @msg = rs[:typefail_msg] || "%label% must be an integer."
                        when MATCH_FAIL_FLOAT     then @msg = rs[:typefail_msg] || "%label% must be a number, such as 1024 or 3.1415 (no commas are allowed)."
                        when MATCH_FAIL_DATE      then @msg = rs[:typefail_msg] || "%label% does not look like a valid date.\nIt should be like: 12/31/2004"
                        when MATCH_FAIL_TIME      then @msg = rs[:typefail_msg] || "%label% does not look like a valid time.\nIt should be like: 11pm or 1:13:57 or 23:00"
                        when MATCH_FAIL_DATETIME  then @msg = rs[:typefail_msg] || "%label% does not look like a valid date/time.\nIt should be like: 12/31/2004 1:13pm"
                        when MATCH_FAIL_CUSTOM    then @msg = rs[:typefail_msg] || "%label% does not look appear to be in a valid format."
                        else
                                raise ArgumentError,"Unrecognized error type passed to ValidForm::ValidationError#new"
                end
                @msg.gsub!(%r|%label%|, field.label || field.name || field.id )
                @type=type
                @field=field
                @value=field.value
        end