PHP code example of harryosmar / plugin-validation
1. Go to this page and download the library: Download harryosmar/plugin-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/ */
harryosmar / plugin-validation example snippets
use PluginSimpleValidate\Validation;
use PluginSimpleValidate\Field;
use PluginSimpleValidate\Libraries\Language;
$language = new Language('en');
$validation = new Validation($this->language);
$emailField = (new Field('email', ''))->
[
'email' => [
'field must be a valid email address',
],
'grant_type' => [
'field is => [
'field is 'field is length must be greater than 5',
],
'scope' => [
'field is
use PluginSimpleValidate\Field;
use PluginSimpleValidate\Validation;
$firstNameField = (new Field('firstname', ''))->llname',
$firstNameField->getValue() . ' ' . $lastNameField->getValue()
))->lengthGreaterOrEqualThan(10);
/** @var Validation $validation */
$validation->addField($firstNameField)->addField($lastNameField)->addField($fullNameField);
if (!$validation->run()) {
$errors = $validation->getErrors();
}
[
[
'firstname' => [
'field is ],
'lastname' => [
'field is ],
'fullname' => [
'field length must be greater or equal than 10',
],
]
];
use PluginSimpleValidate\MultiValues\Field;
use PluginSimpleValidate\Validation;
$firstName = '';
$lastName = '';
/** @var Validation $validation */
$validation->addField((new Field('name'))
->isTrue($firstName !== '', 'first name un()) {
$errors = $validation->getErrors();
}
[
'name' => [
'first name 4',
'last name ength must be at least 10',
]
];
$field = new \PluginSimpleValidate\Field('field', someMethod());
$field->isTrue('this is for error message');
function someMethod() : bool
{
// add logic here
return true;
}
/**
* @var \PluginSimpleValidate\Field $field
*/
$field->isValidPhone('ID'); // `ID` is region code for `indonesia` country
use PluginSimpleValidate\Libraries\Language;
/**
* @var array $translationArray
* $translationArray must have the same format with https://github.com/harryosmar/plugin-validation/blob/master/src/lang/en.php
*/
$language = new Language('pl', $translationArray);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.