The Schemable Validator was developed to streamline the validation processing involved in form submissions.
- 🍨 Vanilla PHP Based: Designed to be independent of specific systems such as CMS platforms.
- ✅ Validation: Built on flexible and powerful validation processing using Respect/Validation, with sanitization features.
- 📂 Data Store: Equipped with a controller that allows for easy storage of validated data for reuse across different pages and processes.
- ⚙️ Customizability: Supports replaceable reply templates through aliases.
composer require uuki/schemable-validator:0.x@dev
Include plugin.
require_once __DIR__ . '/path/to/vendor/uuki/schemable-validator/src/index.php';
Create schema.
use Respect\Validation\Validator as v;
$schema = [
'type' => v::notEmpty()
->setTemplate('Please select an item')
->in(['option1', 'option2', 'option3']),
'name' => v::stringType()->length(1, 50),
'email' => v::email(),
'phone' => v::phone()->length(10, 15),
'url' => v::url(),
'address' => v::stringType()->length(1, 255),
'body' => v::stringType()->length(1, 1000),
'usage' => v::notEmpty()->in(['for_business', 'for_personal']),
'docs' => v::key('error', v::equals(UPLOAD_ERR_OK))
->key('name', v::oneOf(
v::extension('jpg'),
v::extension('png'),
)),
'agreement' => v::trueVal()
];
Create validator instance.
use SchemableValidator\Validator;
$validator = new Validator($schema);
Validation at any time.
$result = $validator->validate($_POST);
name | versions |
---|---|
PHP | ^7.4 || ^8.0 || ^8.1 || ^8.2 |
https://packagist.org/packages/respect/validation#2.2.4
- Some options
- reCAPTCHA
- i18n
pnpm install
pnpm dev # start wp-content mode
https://github.com/WordPress/playground-tools/tree/trunk/packages/wp-now#automatic-modes