Download the PHP package macocci7/purephp-validation without Composer
On this page you can find all versions of the php package macocci7/purephp-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download macocci7/purephp-validation
More information about macocci7/purephp-validation
Files in macocci7/purephp-validation
Package purephp-validation
Short Description illuminate/validation wrapper for pure php.
License MIT
Informations about the package purephp-validation
Purephp Validation
1. Features
Purephp Validation
is a standalone library to use the Illuminate\Validation package outside the Laravel framework.
This library is based on jeffochoa/validator-factory,
This library is customized to use with static calls, like a Laravel Facade:
It also supports Password
rule object and File
rule object.
Additionally and uniquely, Instance
rule object is supported.
2. Contents
- 1. Features
- 2. Contents
- 3. Requirements
- 4. Installation
- 5. Usage
- 5.1. Basic Usage
- 5.2. Setting Traslations Root Path and Language
- 5.3. Using Passowrd Rule Object
- 5.4. Using File Rule Object
- 5.5. Using Instance Rule Object
- 6. Examples
- 7. LICENSE
3. Requirements
- PHP 8.2 or later
- Composer installed
4. Installation
5. Usage
5.1. Basic Usage
First, import autoload.php
into your code (in src/
folder) like this:
Then, create a new instance of the Illuminate\Validation\Validator
as follows:
Now, you can check the validation results:
You can learn more about writing validation rules at the Laravel Official Documentation.
Here's also an example code for basic usage: BasicUsage.php
5.2. Setting Translations Root Path and Language
You'll probably want to place the lang
folder somewhere else outside of vendor/
.
You can set the Translations Root Path before creating an instance of Validator
:
You can also set the Language before creating an instance of Validator
:
Here's an example code for setting Translations Root Path and Language: SetTranslationsRootPath.php
5.3. Using Password Rule Object
You can validate passwords using Laravel's Password
rule object.
You can learn more about Laravel's Password
rule object at the Laravel Official Document.
Here's an example code for using Password
rule object: ValidatePassword.php
5.4. Using File Rule Object
You can validate files using Laravel's File
rule object.
You can learn more about Laravel's File
rule object at the Laravel Official Document.
Here's an example code for using Laravel's File
rule object: ValidateFile.php
5.5. Using Instance Rule Object
You can validate objects using Instance
rule object. (unique feature)
By using Instance::of($class)
method as a rule, you can perform $value instanceof $class
in the validation.
Instance::of()
accepts class name(s) as an argument.
Here's an example code for using Instance
rule object: ValidateInstance.php
6. Examples
- BasicUsage.php
- SetTranslationsRootPath.php
- ValidatePassword.php
- ValidateFile.php
- ValidateInstance.php
7. LICENSE
MIT
Copyright 2024 macocci7