Extends the Laravel validation service with additional rules
Custom Validators for Laravel
By Simon Hampel.
The recommended way of installing this validation library is through Composer:
Require the package via Composer in your composer.json
{
"require": {
"hampel/validate-laravel": "~2.1"
}
}
Run Composer to update the new requirement.
$ composer update
The package is built to work with the Laravel Framework.
Open your Laravel config file config/app.php and add the service provider in the $providers array:
"providers" => array(
...
"Hampel\Validate\Laravel\ValidateServiceProvider"
),
Version 2.0 of this library removes several rules previously available:
unique_or_zero and exists_or_zero have been removed as they were deemed to be of little value
domain, domain_in, tld and tld_in have been moved to a new package hampel/tlds.
The getTlds helper function has also been removed and you should install the hampel/tlds package to gain access to all new functions for retrieving an up-to-date list of all valid TLDs directly from IANA or other sources.
This package adds additional validators for Laravel - refer to Laravel Documentation - Validation for general usage instructions.
bool
The field under validation must be the equivalent of a "boolean" (either true or false) in a variety of forms.
Acceptable values include: "1", "true", "on" and "yes", "0", "false", "off", "no", "", and NULL
ipv4_public
The field under validation must be a public IPv4 address - ie. not in the "private" or "reserved" ranges.
ipv6_public
The field under validation must be a public IPv6 address - ie. not in the "private" or "reserved" ranges.
ip_public
The field under validation must be a public IPv4 or IPv6 address - ie. not in the "private" or "reserved" ranges.
uploaded_file
The field under validation must be an uploaded file of type Symfony\Component\HttpFoundation\File\UploadedFile, as
returned from Input::file(). The file upload must also be valid, that is, the upload must have succeeded with an error
return of UPLOAD_ERR_OK
(see File Upload Error Messages Explained for more details
on file upload errors)