# Prüfungsmeldungen

Jede Prüfung die auf `Zend_Validate` basiert, bietet im Fall einer fehlgeschlagen Prüfung eine oder mehrere Meldungen an. Diese Information kann verwendet werden um eigene Meldungen zu setzen, oder um die Meldungen die eine Prüfung zurückgeben kann zu übersetzen. Die folgende Tabelle zeigt alle vorhandenen Meldungen welche von jeder einzelner Prüfung zurückgegeben wird.

## Vorhandene Prüfmeldungen

Prüfung | Konstante | Meldung
--- | --- | ---
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

Zusätzlich kann man alle Meldungstemplates einer Prüfung mit der Methode `getMessageTemplates()` erhalten. Sie gibt ein Array mit den Meldungen zurück die eine Prüfung im Fall einer fehlgeschlagenen Prüfung zurückgeben könnte.

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

## Begrenzen der Größe einer Prüfungsmeldung

Manchmal ist es notwendig die maximale Größe die eine Prüfungsmeldung haben kann zu begrenzen. Zum Beispiel wenn die View nur eine maximale Größe von 100 Zeichen für die Darstellung auf einer Zeile erlaubt. Um die Verwendung zu vereinfachen, ist `Zend_Validate` dazu in der Lage die maximal zurückgegebene Größe einer Prüfnachricht zu begrenzen.

Um die aktuell gesetzte Größe zu erhalten ist `Zend_Validate::getMessageLength()` zu verwenden. Wenn diese -1 ist, dann wird die zurückgegebene Nachricht nicht begrenzt. Das ist das Standardverhalten.

Um die Größe der zurückgegebenen Nachrichten zu begrenzen ist `Zend_Validate::setMessageLength()` zu verwenden. Man kann diese auf jede benötigte Integer Größe setzen. Wenn die zurückzugebende Nachricht die gesetzte Größe überschreitet, dann wird die Nachricht abgeschnitten und der String '...' wird statt dem Rest der Nachricht hinzugefügt.

    Zend_Validate::setMessageLength(100);

Es ist zu beachten das die gesetzte Länge der Nachrichten für alle Prüfungen verwendet wird, sogar für selbstdefinierte, solange Sie `Zend_Validate_Abstract` erweitern.