zendframework/zend-validator
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
container-interop/container-interop | 1.2.0 | 72.25 kB | MIT | prod | 1 |
zendframework/zend-stdlib | 3.2.1 | 52.72 kB | BSD-3-Clause | prod | 1 |
Zendframework/zend-validator is a package that offers a set of commonly needed validators. This package not only provides validation tools for a wide range of domains, but it also elegantly handles the ability to chain multiple validators together. This chaining mechanism allows you to apply a number of validators to a single datum in a specific order as defined by the user.
To make use of the zendframework/zend-validator in your PHP project, you first need to install this library into your environment. This can be accomplished using the Composer dependency management tool by running the following command in your terminal:
$ composer require zendframework/zend-validator
Once the package has been installed, you can call upon it within your PHP code. An example of its usage can be as follows:
<?php
require 'vendor/autoload.php';
$validator = new Zend\Validator\EmailAddress();
if ($validator->isValid($email)) {
// email appears to be valid
} else {
// email is invalid; print the reasons
foreach ($validator->getMessages() as $message) {
echo "$message\n";
}
}
This example illustrates how you can utilize the EmailAddress validator to check whether a provided email address is valid or not.
The comprehensive documentation for the zendframework/zend-validator can be found online at https://docs.zendframework.com/zend-validator/. This resource is quite valuable, and it provides detailed information on the different validators provided, the chaining mechanism, as well as how to extend the functionality of the package to suit your needs.