# Validation Messages

Each validator which is based on `Zend_Validate` provides one or multiple messages in the case of a failed validation. You can use this information for setting own messages or when you have to translate the messages a validator can return. The following table lists all available messages which are returned by each validator.

## Available Validation Messages

Validator | Constant | Message
--- | --- | ---
Alnum | `NOT_ALNUM` | '%value%' has not only alphabetic and digit characters
`STRING_EMPTY` | '%value%' is an empty string
Alpha | `NOT_ALPHA` | '%value%' has not only alphabetic characters
`STRING_EMPTY` | '%value%' is an empty string
Barcode | --- | messages are thrown by a subclass
Barcode_Ean13 | `INVALID` | '%value%' is an invalid `EAN`-13 barcode
`INVALID_LENGTH` | '%value%' should be 13 characters
`NOT_NUMERIC` | '%value%' should contain only numeric characters
Barcode_UpcA | `INVALID` | '%value%' is an invalid `UPC`-A barcode
`INVALID_LENGTH` | '%value%' should be 12 characters
Between | `NOT_BETWEEN` | '%value%' is not between '%min%' and '%max%', inclusively
`NOT_BETWEEN_STRICT` | '%value%' is not strictly between '%min%' and '%max%'
Ccnum | `LENGTH` | '%value%' must contain between 13 and 19 digits
`CHECKSUM` | Luhn algorithm (mod-10 checksum) failed on '%value%'
Date | `FALSEFORMAT` | '%value%' does not fit given date format
`INVALID` | '%value%' does not appear to be a valid date
Db_Abstract | `ERROR_NO_RECORD_FOUND` | No record matching %value% was found
`ERROR_RECORD_FOUND` | A record matching %value% was found
Digits | `NOT_DIGITS` | '%value%' contains not only digit characters
`STRING_EMPTY` | '%value%' is an empty string
EmailAddress | `INVALID` | '%value%' is not a valid email address in the basic format local-part@hostname
`INVALID_FORMAT` | '%value%' is not a valid email address in the basic format local-part@hostname
`INVALID_HOSTNAME` | '%hostname%' is not a valid hostname for email address '%value%'
`INVALID_MX_RECORD` | '%hostname%' does not appear to have a valid MX record for the email address '%value%'
`DOT_ATOM` | '%localPart%' not matched against dot-atom format
`QUOTED_STRING` | '%localPart%' not matched against quoted-string format
`INVALID_LOCAL_PART` | '%localPart%' is not a valid local part for email address '%value%'
`LENGTH_EXCEEDED` | '%value%' exceeds the allowed length
File_Count | `TOO_MUCH` | Too much files, maximum '%max%' are allowed but '%count%' are given
`TOO_LESS` | Too less files, minimum '%min%' are expected but '%count%' are given
File_Crc32 | `DOES_NOT_MATCH` | The file '%value%' does not match the given crc32 hashes
`NOT_DETECTED` | There was no crc32 hash detected for the given file
`NOT_FOUND` | The file '%value%' could not be found
File_ExcludeExtension | `FALSE_EXTENSION` | The file '%value%' has a false extension
`NOT_FOUND` | The file '%value%' was not found
File_ExcludeMimeType | `FALSE_TYPE` | The file '%value%' has a false mimetype of '%type%'
`NOT_DETECTED` | The mimetype of file '%value%' could not been detected
`NOT_READABLE` | The file '%value%' can not be read
File_Exists | `DOES_NOT_EXIST` | The file '%value%' does not exist
File_Extension | `FALSE_EXTENSION` | The file '%value%' has a false extension
`NOT_FOUND` | The file '%value%' was not found
File_FilesSize | `TOO_BIG` | All files in sum should have a maximum size of '%max%' but '%size%' were detected
`TOO_SMALL` | All files in sum should have a minimum size of '%min%' but '%size%' were detected
`NOT_READABLE` | One or more files can not be read
File_Hash | `DOES_NOT_MATCH` | The file '%value%' does not match the given hashes
`NOT_DETECTED` | There was no hash detected for the given file
`NOT_FOUND` | The file '%value%' could not be found
File_ImageSize | `WIDTH_TOO_BIG` | Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected
`WIDTH_TOO_SMALL` | Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected
`HEIGHT_TOO_BIG` | Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected
`HEIGHT_TOO_SMALL` | Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected
`NOT_DETECTED` | The size of image '%value%' could not be detected
`NOT_READABLE` | The image '%value%' can not be read
File_IsCompressed | `FALSE_TYPE` | The file '%value%' is not compressed, '%type%' detected
`NOT_DETECTED` | The mimetype of file '%value%' could not been detected
`NOT_READABLE` | The file '%value%' can not be read
File_IsImage | `FALSE_TYPE` | The file '%value%' is no image, '%type%' detected
`NOT_DETECTED` | The mimetype of file '%value%' could not been detected
`NOT_READABLE` | The file '%value%' can not be read
File_Md5 | `DOES_NOT_MATCH` | The file '%value%' does not match the given md5 hashes
`NOT_DETECTED` | There was no md5 hash detected for the given file
`NOT_FOUND` | The file '%value%' could not be found
File_MimeType | `FALSE_TYPE` | The file '%value%' has a false mimetype of '%type%'
`NOT_DETECTED` | The mimetype of file '%value%' could not been detected
`NOT_READABLE` | The file '%value%' can not be read
File_NotExists | `DOES_EXIST` | The file '%value%' does exist
File_Sha1 | `DOES_NOT_MATCH` | The file '%value%' does not match the given sha1 hashes
`NOT_DETECTED` | There was no sha1 hash detected for the given file
`NOT_FOUND` | The file '%value%' could not be found
File_Size | `TOO_BIG` | Maximum allowed size for file '%value%' is '%max%' but '%size%' detected
`TOO_SMALL` | Minimum expected size for file '%value%' is '%min%' but '%size%' detected
`NOT_FOUND` | The file '%value%' could not be found
File_Upload | `INI_SIZE` | The file '%value%' exceeds the defined ini size
`FORM_SIZE` | The file '%value%' exceeds the defined form size
`PARTIAL` | The file '%value%' was only partially uploaded
`NO_FILE` | The file '%value%' was not uploaded
`NO_TMP_DIR` | No temporary directory was found for the file '%value%'
`CANT_WRITE` | The file '%value%' can't be written
`EXTENSION` | The extension returned an error while uploading the file '%value%'
`ATTACK` | The file '%value%' was illegal uploaded, possible attack
`FILE_NOT_FOUND` | The file '%value%' was not found
`UNKNOWN` | Unknown error while uploading the file '%value%'
File_WordCount | `TOO_MUCH` | Too much words, maximum '%max%' are allowed but '%count%' were counted
`TOO_LESS` | Too less words, minimum '%min%' are expected but '%count%' were counted
`NOT_FOUND` | The file '%value%' could not be found
Float | `NOT_FLOAT` | '%value%' does not appear to be a float
GreaterThan | `NOT_GREATER` | '%value%' is not greater than '%min%'
Hex | `NOT_HEX` | '%value%' has not only hexadecimal digit characters
Hostname | `IP_ADDRESS_NOT_ALLOWED` | '%value%' appears to be an IP address, but IP addresses are not allowed
`UNKNOWN_TLD` | '%value%' appears to be a DNS hostname but cannot match TLD against known list
`INVALID_DASH` | '%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position
`INVALID_HOSTNAME_SCHEMA` | '%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'
`UNDECIPHERABLE_TLD` | '%value%' appears to be a DNS hostname but cannot extract TLD part
`INVALID_HOSTNAME` | '%value%' does not match the expected structure for a DNS hostname
`INVALID_LOCAL_NAME` | '%value%' does not appear to be a valid local network name
`LOCAL_NAME_NOT_ALLOWED` | '%value%' appears to be a local network name but local network names are not allowed
Iban | `NOTSUPPORTED` | '%value%' does not have IBAN
`FALSEFORMAT` | '%value%' has a false format
`CHECKFAILED` | '%value%' has failed the IBAN check
Identical | `NOT_SAME` | The token '%token%' does not match the given token '%value%'
`MISSING_TOKEN` | No token was provided to match against
InArray | `NOT_IN_ARRAY` | '%value%' was not found in the haystack
Int | `NOT_INT` | '%value%' does not appear to be an integer
Ip | `NOT_IP_ADDRESS` | '%value%' does not appear to be a valid IP address
LessThan | `NOT_LESS` | '%value%' is not less than '%max%'
NotEmpty | `IS_EMPTY` | Value is required and can't be empty
Regex | `NOT_MATCH` | '%value%' does not match against pattern '%pattern%'
StringLength | `TOO_SHORT` | '%value%' is less than %min% characters long
`TOO_LONG` | '%value%' is greater than %max% characters long

Additionally you can retrieve all message templates of a validator with the method `getMessageTemplates()`. It returns you an array with the messages a validator could return in the case of a failed validation.

    $validator = new Zend_Validate_Alnum();
    $messages  = $validator->getMessageTemplates();

## Limit the size of a validation message

Sometimes it is necessary to limit the maximum size a validation message can have. For example when your view allows a maximum size of 100 chars to be rendered on one line. To simplify the usage, `Zend_Validate` is able to automatically limit the maximum returned size of a validation message.

To get the actual set size use `Zend_Validate::getMessageLength()`. If it is -1, then the returned message will not be truncated. This is default behaviour.

To limit the returned message size use `Zend_Validate::setMessageLength()`. Set it to any integer size you need. When the returned message exceeds the set size, then the message will be truncated and the string '...' will be added instead of the rest of the message.

    Zend_Validate::setMessageLength(100);

Note that the set message length is used for all validators, even for self defined ones as long as they extend `Zend_Validate_Abstract`.