Previous Next

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
NOT_YYYY_MM_DD '%value%' is not of the format YYYY-MM-DD
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:

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

Previous Next
Introduction to Zend Framework
Présentation
Installation
Zend_Acl
Introduction
Affiner les Contrôles d'Accès
Utilisation avancée
Zend_Amf
Introduction
Zend_Amf_Server
Zend_Application
Introduction
Zend_Application Quick Start
Théorie générale
Exemples
Fonctionnalités principales
Plugins de ressources disponibles
Zend_Auth
Introduction
Authentification avec une table de base de données
Authentification "Digest"
Adaptateur d'authentification HTTP
LDAP Authentication
Authentification OpenID
Zend_Cache
Introduction
Aspect théorique
Les frontends Zend_Cache
Les backends Zend_Cache
Zend_Captcha
Introduction
Opération Captcha
Adaptateurs CAPTCHA
Zend_CodeGenerator
Introduction
Exemples Zend_CodeGenerator
Zend_CodeGenerator Réference
Zend_Config
Introduction
Aspect théorique
Zend_Config_Ini
Zend_Config_Xml
Zend_Config_Writer
Zend_Config_Writer
Zend_Console_Getopt
Introduction
Déclarer les règles Getopt
Extraire les options et les arguments
Configurer Zend_Console_Getopt
Zend_Controller
Zend_Controller - Démarrage rapide
Fondations de Zend_Controller
Le contrôleur frontal (Front Controller)
L'objet Requête
Routeur Standard
Le distributeur
Contrôleurs d'action
Aides d'action (Helper)
Objet de réponse
Plugins
Utilisation de conventions de dossiers modulaires
Exceptions avec MVC
Migrer depuis des versions précédentes
Zend_Currency
Introduction à Zend_Currency
How to Work with Currencies
Migrer depuis des versions antérieures
Zend_Date
Introduction
Aspect théorique
Méthodes de base
Zend_Date API Overview
Créer des dates
Constants for General Date Functions
Exemples concrets
Zend_Db
Zend_Db_Adapter
Zend_Db_Statement
Zend_Db_Profiler
Zend_Db_Select
Zend_Db_Table
Zend_Db_Table_Row
Zend_Db_Table_Rowset
Relations Zend_Db_Table
Zend_Db_Table_Definition
Zend_Debug
Afficher des informations
Zend_Dojo
Introduction
Zend_Dojo_Data: dojo.data Envelopes
Les aides de vues Dojo
Les éléments de formulaire et les décorateurs Dojo
Zend_Dojo build layer support
Zend_Dom
Introduction
Zend_Dom_Query
Zend_Exception
Utiliser les exceptions
Zend_Feed
Introduction
Importer des flux
Obtenir des flux à partir de pages Web
Consommer un flux RSS
Consommer un flux Atom
Consommer une entrée Atom particulière
Modifier la structure du flux ou des entrées
Classes personnalisées pour les flux et entrées
Zend_Feed_Reader
Zend_File
Zend_File_Transfer
Validateurs pour Zend_File_Transfer
Filtres pour Zend_File_Transfer
Migrer à partir des versions précédentes
Zend_Filter
Introduction
Classes de filtre standards
Chaînes de filtrage
Écriture de filtres
Zend_Filter_Input
Zend_Filter_Inflector
Migrating from Previous Versions
Zend_Form
Zend_Form
Zend_Form démarrage rapide
Creating Form Elements Using Zend_Form_Element
Creating Forms Using Zend_Form
Créer un visuel personnalisé en utilisant Zend_Form_Decorator
Standard Form Elements Shipped With Zend Framework
Décorateurs standards fournis avec Zend Framework
Internationaliser un formulaire Zend_Form
Advanced Zend_Form Usage
Zend_Gdata
Introduction
Authentification par procédé AuthSub
Using the Book Search Data API
Authentification avec ClientLogin
Using Google Calendar
Using Google Documents List Data API
Using Google Health
Using Google Spreadsheets
Using Google Apps Provisioning
Using Google Base
Utilisation des albums Web Picasa
Using the YouTube Data API
Attraper les exceptions Gdata
Zend_Http
Introduction
Zend_Http_Client - Utilisation avancée
Zend_Http_Client - Adaptateurs de connexion
Migrer depuis les versions précédentes
Zend_Http_Cookie and Zend_Http_CookieJar
Zend_Http_Response
Zend_InfoCard
Introduction
Zend_Json
Introduction
Utilisation de base
Utilisation avancée de Zend_Json
XML to JSON conversion
Zend_Json_Server - JSON-RPC server
Zend_Layout
Introduction
Zend_Layout - Démarrage rapide
Zend_Layout options de configuration
Zend_Layout, utilisation avancée
Zend_Ldap
Introduction
API overview
Usage Scenarios
Tools
Object oriented access to the LDAP tree using Zend_Ldap_Node
Getting information from the LDAP server
Serializing LDAP data to and from LDIF
Zend_Loader
Charger les fichiers et les classes dynamiquement
L'autoloader
Autoloaders de ressources
Chargeur de Plugins
Zend_Locale
Introduction
Using Zend_Locale
Normalization and Localization
Working with Dates and Times
Supported locales
Migrer à partir des versions précédentes
Zend_Log
Présentation
Rédacteurs (Writers)
Formateurs (mise en forme)
Filtres
Zend_Mail
Introduction
Envoyer des émail en utilisant SMTP
Envoyer plusieurs émail par connexion SMTP
Utiliser différents transports
Émail HTML
Fichiers joints
Ajouter des destinataires
Contrôler les limites MIME
En-têtes additionnels
Jeux de caractères
Encodage
Authentification SMTP
Sécuriser les transports SMTP
Lire des émail
Zend_Measure
Introduction
Création d'une mesure
Récupérer des mesures
Manipuler des mesures
Types de mesures
Zend_Memory
Présentation
Manager de mémoire
Objet mémoire
Zend_Mime
Zend_Mime
Zend_Mime_Message
Zend_Mime_Part
Zend_Navigation
Introduction
Pages
Containers
Migrating from Previous Versions
Zend_OpenId
Introduction
Zend_OpenId_Consumer Basics
Zend_OpenId_Provider
Zend_Paginator
Introduction
Utilisation
Configuration
Utilisation avancée
Zend_Pdf
Introduction
Créer et charger des documents PDF
Sauvegarder les changement dans un document PDF
Les pages d'un document
Dessiner
Interactive Features
Informations du document et métadonnées
Exemple d'utilisation du module Zend_Pdf
Zend_ProgressBar
Zend_ProgressBar
Zend_Queue
Introduction
Example usage
Framework
Adapters
Customizing Zend_Queue
Stomp
Zend_Reflection
Introduction
Zend_Reflection Exemples
Réference de Zend_Reflection
Zend_Registry
Utiliser le registre
Zend_Rest
Introduction
Zend_Rest_Client
Zend_Rest_Server
Zend_Search_Lucene
Vue d'ensemble
Créer des index
Searching an Index
Query Language
Query Construction API
Jeu de caractères
Extensibility
Agir avec Lucene Java
Avancé
Bonnes pratiques
Zend_Server
Introduction
Zend_Server_Reflection
Zend_Service
Introduction
Zend_Service_Akismet
Zend_Service_Amazon
Zend_Service_Amazon_Ec2
Zend_Service_Amazon_Ec2: Instances
Zend_Service_Amazon_Ec2: Windows Instances
Zend_Service_Amazon_Ec2: Reserved Instances
Zend_Service_Amazon_Ec2: CloudWatch Monitoring
Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)
Zend_Service_Amazon_Ec2: Elastic Block Stroage (EBS)
Zend_Service_Amazon_Ec2: Elastic IP Addresses
Zend_Service_Amazon_Ec2: Keypairs
Zend_Service_Amazon_Ec2: Regions and Availability Zones
Zend_Service_Amazon_Ec2: Security Groups
Zend_Service_Amazon_S3
Zend_Service_Amazon_Sqs
Zend_Service_Audioscrobbler
Zend_Service_Delicious
Zend_Service_Flickr
Zend_Service_Nirvanix
Zend_Service_ReCaptcha
Zend_Service_Simpy
Introduction
Zend_Service_StrikeIron
Zend_Service_StrikeIron: Bundled Services
Zend_Service_StrikeIron: Advanced Uses
Zend_Service_Technorati
Zend_Service_Twitter
Zend_Service_Yahoo
Zend_Session
Introduction
Usage basique
Utilisation avancée
Gestion générale de la session
Zend_Session_SaveHandler_DbTable
Zend_Soap
Zend_Soap_Server
Zend_Soap_Client
WSDL
Auto découverte
Zend_Tag
Introduction
Zend_Tag_Cloud
Zend_Test
Introduction
Zend_Test_PHPUnit
Zend_Test_PHPUnit_Db
Zend_Text
Zend_Text_Figlet
Zend_Text_Table
Zend_TimeSync
Introduction
Utiliser Zend_TimeSync
Zend_Tool_Framework
Introduction
Using the CLI Tool
Architecture
Creating Providers to use with Zend_Tool_Framework
Shipped System Providers
Extending and Configuring Zend_Tool_Framework
Zend_Tool_Project
Introduction
Create A Project
Zend Tool Project Providers
Zend_Translate
Introduction
Adaptateurs pour Zend_Translate
Utiliser les adaptateurs de traduction
Creating source files
Additional features for translation
Plural notations for Translation
Migrer à partir des versions précédentes
Zend_Uri
Zend_Uri
Zend_Validate
Introduction
Classes de validation standard
Chaînes de validation
Écrire des validateurs
Validation Messages
Zend_Version
Lire la version de Zend Framework
Zend_View
Introduction
Scripts de contrôleur
Scripts de vue
Aides de vue
Zend_View_Abstract
Migration depuis les versions précédentes
Zend_Wildfire
Zend_Wildfire
Zend_XmlRpc
Introduction
Zend_XmlRpc_Client
Zend_XmlRpc_Server
Configuration système requise par Zend Framework
Introduction
Convention de codage PHP de Zend Framework
Vue d'ensemble
Formatage des fichiers PHP
Conventions de nommage
Style de codage
Zend Framework Documentation Standard
Overview
Documentation File Formatting
Recommendations
Recommended Project Structure for Zend Framework MVC Applications
Overview
Recommended Project Directory Structure
Module Structure
Rewrite Configuration Guide
Zend Framework Performance Guide
Introduction
Chargement des classes
Zend_Db Performance
Internationalisation (i18n) and Localisation (l10n)
View Rendering
Informations de copyright