PHP code example of wpdiggerstudio / wpzylos-validation
1. Go to this page and download the library: Download wpdiggerstudio/wpzylos-validation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wpdiggerstudio / wpzylos-validation example snippets
use WPZylos\Framework\Validation\Validator;
$validator = new Validator($data, [
'name' => ['validator->fails()) {
$errors = $validator->errors();
}
Validator::extend('phone', function ($attribute, $value) {
return preg_match('/^\+?[1-9]\d{1,14}$/', $value);
}, 'The :attribute must be a valid phone number.');
// Usage
$rules = ['phone' => ['
if ($validator->fails()) {
foreach ($validator->errors()->all() as $error) {
echo $error;
}
// Get errors for a specific field
$emailErrors = $validator->errors()->get('email');
}
$validator = new Validator($data, $rules, [
'email.;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.