PHP code example of itwmw / engine-validate-attributes
1. Go to this page and download the library: Download itwmw/engine-validate-attributes 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/ */
itwmw / engine-validate-attributes example snippets
use Itwmw\Validate\Attributes\Validator;
class UserController
{
#[Validator(validate: UserValidate::class, scene: 'login')]
public function login()
{
}
#[Validator(validate: UserValidate::class, fields: ['user', 'pass'])]
public function register()
{
}
}
use Itwmw\Validate\Attributes\ValidateAttributesFactory;
use Itwmw\Validate\Middleware\ValidateMiddlewareConfig;
ValidateMiddlewareConfig::instance()->setValidateFactory(new ValidateAttributesFactory());
$validate = (new Itwmw\Validate\Attributes\ValidateAttributesFactory())->getValidate(UserController::class,"login");
$validate->check($userInput);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.