marwanalsoltany / mighty
The last validation library you will ever need!
Fund package maintenance!
Ko-Fi
Installs: 1 331
Dependents: 0
Suggesters: 0
Security: 0
Stars: 59
Watchers: 3
Forks: 2
Open Issues: 0
pkg:composer/marwanalsoltany/mighty
Requires
- php: >=8.1
- ext-ctype: *
- ext-dom: *
- ext-intl: *
- ext-json: *
- ext-mbstring: *
Requires (Dev)
- code-lts/doctum: ^5.5
- friendsofphp/php-cs-fixer: ^3.9
- phpbench/phpbench: ^1.2
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-10-09 21:12:05 UTC
README
The last validation library you will ever need!
Table of Contents
Installation
About Mighty
Quickstart
mVEL
Examples
Constraints
Validations
Documentation
Specification
Changelog
If you like this project and would like to support its development, giving it a ⭐ would be appreciated!
Key Features
- Zero dependencies.
- Framework agnostic, can be integrated in any codebase.
- Expressive, intuitive and easy to get along with over 250 built-in validation rules.
Installation
composer require marwanalsoltany/mighty
About Mighty
Validation is a common task in any web application. Data passed to the application via forms —or any type of input for that matter— must always be validated against a set of rules. Mighty can handle in an easy and expressive way.
Mighty is fast, powerful, robust, and easy to use validation library that is just fun to work with, it makes validating any data a breeze. Thanks to the power of the Mighty Validation Expression Language (mVEL) it is not like anything you've seen before. With its validation approach and over 250 built-in rules there is pretty much nothing that you cannot validate with it, in a very expressive and compact manner. Simply put, Mighty is validation on steroids! It is indeed the last validation library you will ever need.
Mighty provides several different approaches to validate data. It's most common use-case is validating incoming data via HTTP requests, but it of course is not limited to that; Mighty provides also attributes in the form of constraints to easily validate models and/or any kind of objects.
Mighty includes a wide variety of convenient validation rules that you may apply as a single rule or combine them with each other using operators to build up even more complex validations.
Quickstart
To learn about Mighty's powerful validation features, let's cut straight to the point and take a look at some examples:
General Data Validation
Validating form data using the Validator::class:
use MAKS\Mighty\Validator; $validator = new Validator(); $validator ->setData([ 'name' => 'John Doe', 'username' => 'john.doe', 'password' => 'Super@Secret#123', 'email' => 'john@doe.com', 'hobbies' => ['coding', 'design', 'sports'], ]) ->setValidations([ // required&string&between:3,255 'name' => $validator->validation()->required()->string()->between(3, 255), // required&string&matches:/[a-z0-9._-]/i 'username' => $validator->validation()->required()->string()->matches('/[a-z0-9._-]/i'), // required&string&min:8 'password' => $validator->validation()->required()->string()->min(8), // required&email 'email' => $validator->validation()->required()->email(), // null^(required&array&max:5) 'hobbies' => $validator ->validation() ->null() ->xor() ->group(fn ($validation) => $validation ->array() ->max(5) ), // null|(if:${hobbies.validations.array}&(string&min:3)) // hobby can be null or a string with at least 3 characters if hobbies is an array 'hobbies.*' => $validator ->validation() ->null() ->or() ->group(fn ($validation) => $validation ->if('${hobbies.validations.array}') ->open() ->string() ->min(3) ->close() ), ]) ->validate(); $result = $validator->isOK(); // boolean result of the overall validation result $errors = $validator->getErrors(); // an array of results of validations that failed $results = $validator->getResults(); // an array of results of all validations $validator->check(); // void or throws an exception with a nicely formatted message of what exactly went wrong
Objects Validation
Validating the state of an object using Constraint::class attributes:
use MAKS\Mighty\Validation\Strategy; use MAKS\Mighty\Validation\Behavior; use MAKS\Mighty\Validation\Operator; use MAKS\Mighty\Validation\Constraint; use MAKS\Mighty\Validation\Constraint as Assert; use MAKS\Mighty\Validation\Constraint\ValidatableObjectInterface; use MAKS\Mighty\Validation\Constraint\ValidatableObjectTrait; class ValidatableObject implements ValidatableObjectInterface { use ValidatableObjectTrait; #[Assert\Rule\Equals('CONST')] public const CONST = 'CONST'; #[Assert\Rule\In(['STATIC', 'VAR'])] public static $static = 'VAR'; #[Assert\Rule\StringConstraint] #[Assert\Rule\StringCharset('UTF-8')] #[Assert\Rule\Between(3, 99)] public $default = 'DEFAULT'; #[Assert\Rule\StringConstraint] #[Assert\Rule\StringContains('<element>')] #[Assert\Rule\Xml] public $xml = '<?xml version="1.0"?><element></element>'; #[Assert\Rule\ArrayConstraint] #[Assert\Shape([ 'string' => new Assert\Rule\Str, 'array' => new Assert\Rule\Arr, ])] public $array = [ 'string' => 'value', 'array' => [], ]; #[Assert\Rule\ObjectConstraint] #[Assert\Rule\ObjectIsInstanceOf(ValidatableObjectInterface::class)] #[Assert\Valid(message: 'Not valid')] public $object; #[Assert\Callback('is_scalar', 'Data is not scalar')] #[Constraint('string&min:3', strategy: Strategy::FailLazy, messages: [ 'string' => 'Must be string.', 'min' => 'Must be longer than ${@arguments.0}.', ])] public function getDefault() { return $this->default; } #[Assert\Compound([ new Assert\Rule\Str, new Assert\Compound([ new Assert\Rule\Arr, new Assert\Compound([ new Assert\Rule\Blank, ], Operator::Not), ], Operator::And), ], Operator::Xor, Behavior::Pessimistic, Strategy::FailLazy)] public static function getStaticProperty() { return static::$static; } } $object = new ValidatableObject(); $result = $object->isValid(); // boolean result of the overall validation result $results = $object->validate(); // an array of results of all validations $object->check(); // void or throws an exception with a nicely formatted message of what exactly went wrong
An example of the output of validating a validatable object would look like this:
// check out the previous snippet see the used constraints $object = new ValidatableObject(); $object->object = new class implements ValidatableObjectInterface { use ValidatableObjectTrait; // some properties and their validation constraints ... }; $object->default = null; // this must be a string $object->check(); // ValidationFailedException::class // Data failed to pass the validation. // (01) The value (null) of the "ValidatableObject->default" property failed to pass the validation [string]. Problem: Value must be a string. // (02) The value (null) of the "ValidatableObject->default" property failed to pass the validation [string.charset:"UTF-8"]. Problem: Value must be encoded in one of the following charsets: ["UTF-8"]. // (03) The value (null) of the "ValidatableObject->default" property failed to pass the validation [between:3,99]. Problem: Value must be between 3 and 99 or have a value/count/length that is between 3 and 99. // (04) The return value (null) of the "ValidatableObject->getDefault()" method failed to pass the validation [callback]. Problem: Data is not scalar. // (05) The return value (null) of the "ValidatableObject->getDefault()" method failed to pass the validation [string&min:3]. Problems: Must be string; Must be longer than 3.
Check also ValidatableObject and ValidatableObjectChild.
Hint: More examples can be found in the Examples section.
Mighty Validation Expression Language
Mighty has the concept of Validation Expression. The Validation Expression in its simplest forms is just a string that describes how Mighty should validate the given data. These strings are based on the Mighty Validation Expression Language Specification (mVEL). mVEL is pretty simple, human-readable and easy to cope with. It is a combination of well established concepts and/or specifications like Boolean Algebra, Bitwise Operators, JSON, and CSV.
Therefore, Validation Expression may be defined as a string that contains some rules separated by Bitwise Operators which will build an expression that when evaluated using Boolean Algebra logic, will result in the final result of the validation. The rules can have arguments, the types of these arguments can be denoted using the same rules of JSON types. A rule can also have multiple arguments and the arguments are separated by commas (CSV).
For example required&string&between:2,255|null is a valid Validation Expression, this expression can be understood as the following:
- The expression has four rules.
- The expression contains the rules:
requiredAsserts that the input is present.stringAsserts that the input is a string.between:2,255Asserts that the input is a string with a length between 2 and 255.nullAsserts that the input is null.
- The final result is the result of evaluating the expression resulting from the result of each rule glued together using bitwise operators.
The required&string&between:2,255|null expression means that the input must be present; AND of type string; AND between 2 and 255 in length; OR null. So it's a nullable string that when is not null must be between 2 and 255 characters long.
Lets say the the input was "Mighty is Awesome!", the result of the expression required&string&between:2,255|null against that input would be 1&1&1|0 which will result in 1 which is true, if the input was null the result would be 0&0&0|1 = 1, if the input was X the result would be 0&0&0|0 = 0, etc ...
Unlike other validations implementations, the concept of Boolean Algebra using Bitwise Operators, gives the possibility to build up complex validations that are very readable and compact while keeping the rules to a minimum number, reusing existing logic in reversed or compound manner, and finally keeping the code base as DRY as it can be. The benefits can be summarized in the following points:
- A rule can be NOTed (using
~) to do the exact opposite of what it normally does. - A complex rule can be the result of ANDing (using
&), ORing (using|), or XORing (using^), two or more simple rules. - Rules can be grouped together and/or given higher precedence by using parentheses, namely OPEN (using
() and CLOSE (using)). - A Validation Expression can also have behavior, which is a character the prefixes the Validation Expression string that will affect all rules. Available behaviors are:
- NORMAL: execute all rules, default behavior (no prefix).
- OPTIMISTIC: stop executing rules after the first success (
?prefix). - PESSIMISTIC: stop executing rules after the first failure (
!prefix).
- Readability can be improved by aliasing some rules or adding rules sets as macros and executing them using the
[macro]syntax.
Also the concept of JSON ensures arguments data-types safety, and the concept of CSV makes sure the arguments list has clear parsing rules.
The nicest thing, you don't have to memorize all the rules nor the Validation Expression Language syntax. The Validation class is a fluent interface that can be used to build a Validation Expression. It knows about all Mighty available rules and has full IDE-Intellisense support to make it as easy as it gets. For example:
use MAKS\Mighty\Validation; // the validation expression: `required&string&between:2,255|null` // can be constructed using the Validation::class as follows: $validation = (new Validation())->required()->string()->between(2, 255)->or()->null(); // AND is the default operator // or statically: $validation = Validation::required()->string()->between(2, 255)->or()->null();
Fact: It usually takes more words to describe what a validation expression does than the validation expression itself!
Examples
Here are some examples of real world scenarios:
Validating a Single Value
use MAKS\Mighty\Validator; $result = ($validator = new Validator()) ->validateOne( '123', $validator ->validation() // can be an integer or float or a string that is numeric // this example is only for demonstration only, // the same result can be achieved using numeric() only ->integer()->or()->float()->or()->group( fn ($validation) => $validation->string()->and()->numeric() ) ) ->toArray(); // $result would look something like this: [ 'value' => '123', 'result' => true, 'validations' => [ 'integer' => false, 'float' => false, 'string' => true, 'numeric' => true, ], 'errors' => [], 'metadata' => [ 'basis' => 'integer|float|(string&numeric)', 'rules' => 'integer|float|(string&numeric)', 'expression' => '0|0|(1&1)', ], ]; // you can also simply use the static helper Validator::validateData($data, $validation);
Validating Structured Data
use MAKS\Mighty\Validator; use App\Service\HaveIBeenPwnedService as PasswordService; $validator = new Validator(); $data = [ 'name' => 'John Doe', 'age' => 32, 'email' => 'john.doe@domian.tld', 'username' => 'john.doe', 'password' => 'Secret@123', 'image' => '/path/to/image.png', 'submission' => 'now', 'consent' => 'yes', 'data' => [ 'nickname' => 'JOE', 'number' => 7, 'hobbies' => [ 'coding', 'cooking', 'reading', ] ], ]; $validations = [ 'name' => $validator->validation()->required()->string()->stringCharset(['UTF-8', 'ASCII'])->pessimistic(), // or using mVEL => required&string&string.charset:'["UTF-8","ASCII"]' 'age' => $validator->validation()->required()->integer()->min(18), // or using mVEL => required&integer&min:18 'email' => $validator->validation()->required()->email()->macro('gmail'), // or using mVEL => required&email&[gmail] 'username' => $validator->validation()->required()->username(), // or using mVEL => required&username 'password' => $validator->validation()->required()->password()->callback(fn ($input) => !PasswordService::isPwned($input)), // or using mVEL => required&password (NOTE: callback ist not possible, it requires a Validation::class instance that is bound to the Validator::class instance) 'image' => $validator->validation()->null()->xor()->group(fn () => $this->image()->imageDimensions(1920, 1080, '<=')), // or using mVEL => null^(image&image.dimensions:1920,1080,"<=") 'submission' => $validator->validation()->required()->datetime()->datetimeLt('2022-12-07'), // or using mVEL => required&datetime&datetime.lt:"2022-12-07" 'consent' => $validator->validation()->assert('${age.value}', 18, '>=')->or()->accepted()->or()->assertEquals('${this}', 'granted')->optimistic(), // or using mVEL => ?assert:${age.value},18,">="|accepted|assert.equals:${this},"granted" 'data' => $validator->validation()->required()->array()->arrayHasKey('nickname'), // or using mVEL => required&array&array.hasKey:"nickname" 'data.*' => $validator->validation()->scalar()->or()->array()->optimistic(), // or using mVEL => ?scalar|array 'data.nickname' => $validator->validation()->string()->min(2)->max(32), // or using mVEL => string&min:2&max:32 'data.hobbies.*' => $validator->validation()->ifEq('${data.hobbies.validations.array}', false)->or()->group(fn () => $this->string()->min(3)), // or using mVEL => if.eq:${data.hobbies.validations.array},false|(string&min:3) ]; $labels = [ 'name' => 'Name', 'age' => 'Age', 'email' => 'E-Mail', 'password' => 'Password', 'image' => 'Image', 'data' => 'Data', 'data.*' => 'Value of data', 'consent' => 'Consent', ]; $messages = [ '*' => [ // this will be expanded for all fields 'required' => '${@label} is a required field.', ], 'age' => [ 'min' => '${@label} must be at least ${@arguments.0}.', ], 'username' => [ 'matches' => '${@label} must contain letters, numbers, and the following characters ".-_" only.', ], 'consent' => [ 'assert' => 'You must be at least ${@arguments.1} years old to submit this form.', ] ]; $validator ->setData($data) ->setValidations($validations) ->setMessages($messages) ->setLabels($labels) ->validate(); $results = $validator->getResults(); // $result should look something like this: [ // this will actually be a Result object // array syntax is used here for demonstration purposes 'name' => [ 'key' => 'name', 'value' => 'John Doe', 'result' => true, 'validations' => [ 'required' => true, 'string' => true, 'string.charset' => true, ], 'errors' => [], 'metadata' => [ 'basis' => '!required&string&string.charset:["UTF-8","ASCII"]', 'rules' => 'required&string&string.charset:["UTF-8","ASCII"]', 'expression' => '1&1&1', ], ], // other validations ... ]; // you can also simply use the static helper Validator::validateData($data, $validations);
Hint: When providing message overrides to the Validator::class, it is advised to use the Rule\Validation::class to set array keys. This class contains all Mighty built-in rules names as class constants.
Extending the Validator
The validator can be extended in three ways:
- By adding a rule.
- By adding an alias.
- By adding a macro.
use MAKS\Mighty\Validator; use MAKS\Mighty\Rule; $validator = new Validator(); // adding a new rule $validator->addRule( (new Rule()) ->name('equals') ->arguments(['string']) ->callback(fn (string $input, mixed $expected): bool => $input == $expected) ->parameters(['@input', '@arguments.0']) ->comparison(['@output', '===', true]) ->example('equals:value') ->description('Asserts that the input is equal to the given value.') ); // adding a new rule alias $validator->addRuleAlias('eq', 'equals'); // adding a new rules macro $validator->addRuleMacro('gmail', 'string&email&matches:"/@gmail\.com$/i"'); $results = $validator->validateAll( [ 'name' => 'John', 'email' => 'john@doe.com', ], [ 'name' => 'eq:John', 'email' => 'required&[gmail]', ] ); // $results should look like this: [ // items will actually be a Result object // array syntax is used here for demonstration purposes 'name' => [ 'key' => 'name', 'value' => 'John', 'result' => true, 'validations' => [ 'eq' => true, ], 'errors' => [], 'metadata' => [ 'basis' => 'eq:John', 'rules' => 'eq:John', 'expression' => '1', ], ], 'email' => [ 'key' => 'email', 'value' => 'john@gmail.com', 'result' => false, 'validations' => [ 'required' => true, 'string' => true, 'email' => true, 'matches' => false, ],, 'errors' => [], 'metadata' => [ 'basis' => 'required&[gmail]', 'rules' => 'required&(string&email&matches:"/@gmail\.com$/i")', 'expression' => '1&(1&1&0)', ], ], ];
Hint: Check out the default rules, aliases, and macros of the Validator to see more examples.
Constraints
Mighty consists of over 250 rules/attributes that can be used to validate any data or the values of classes, class constants, properties, and methods.
The attributes are split into three main groups:
- Generic Constraint Attributes
- Special Constraint Attributes
- Rule Constraint Attributes
Generic Constraint Attributes Group
The Generic Constraint Attributes are located under the MAKS\Mighty\Validation namespace.
This group consists currently of one attribute only; that is the Constraint attribute. This attribute takes a Validation Expression to validate the data it is applied to. It is also the base class for all other attributes.
Special Constraint Attributes Group
The Special Constraint Attributes are located under the MAKS\Mighty\Validation\Constraint namespace.
This group contains attributes that do a specific job that is available only in the context of attributes. It consists of the following attributes:
Rule: This attribute is used to validate any data using a single validation rule. It is also the base class for all attributes in the Rule Constraint Attributes Group.Callback: This attribute is used to validate any data using a callback function.Valid: This attribute is used to validate the validity of a validatable object.Shape: This attribute is used to validate the shape of an array or object. Note that this is the only attribute that validates a set of values (structured data) rather than a single value.Compound: This attribute is used to combine a set of constraints to build up a Validation Expression. The constraints can be combined using any operator, and can also have a behavior. It serves as an object-oriented way to build up a Validation Expression.
Note: Note that the constraints that are allowed to be used with the Shape::class and Compound::class attributes must be an actual instances of the Constraint::class, Rule::class, or Compound::class. The Callback::class, Valid::class, or Shape::class of the Special Constraint Attributes Group are NOT allowed. If you have a need for this feature, open an issue and we'll discuss implementing it
Rule Constraint Attributes Group
The Rule Constraint Attributes are located under the MAKS\Mighty\Validation\Constraint\Rule namespace.
This group contains attributes that are based on a single validation rule. It consists of most of the attributes Mighty provides. Refer to the Validations section for the full list.
Adding a Custom Constraint
Mighty has a huge list of built-in constraints, it's really rare that you will need anything other than what Mighty provides. Nonetheless, sometimes the need arises for a custom constraint, the is how you can achieve that:
<?php declare(strict_types=1); namespace App\Validation\Constraint; use Attribute; use MAKS\Mighty\Rule; use MAKS\Mighty\Result; use MAKS\Mighty\Validation\Strategy; use MAKS\Mighty\Validation\Constraint; use MAKS\Mighty\Validation\Constraint\ValidatesOne; // use the ValidatesMany interface if your Constraint returns a collection of Result objects use MAKS\Mighty\Validation\Constraint\ValidatesMany; #[Attribute( Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD )] class MyCustomConstraint extends Constraint implements ValidatesOne { public function __construct( ?string $message = null, Strategy $strategy = Strategy::FailFast, ) { parent::__construct( validation: 'app.myCustomConstraint', messages: ['app.myCustomConstraint' => $message], strategy: $strategy ); } public function validate(mixed $value = null): Result { // it is really up to you, how you handle this // you will just work with a normal Mighty Validator // here we're just preparing the data to pass to the Validator $name = ''; $data = [$name => $value]; $validations = [$name => $this->validation]; $messages = [$name => [$this->validation => $this->messages[$this->validation] ?? null]]; $labels = [$name => static::class]; // you can reuse the built-in rules or // add you own Rule that handles your custom logic $result = $this ->getValidator() ->addRule( // see MAKS\Mighty\Rule for more info (new Rule()) ->setName('app.myCustomConstraint') ->setCallback(static fn ($input) => $input /* here comes your logic */) ->setParameters(['@input']) // rule callback dependencies ->setMessage('${@label} must follow my custom constraint validation.') // this is the default message ) ->setData($data) ->setValidations($validations) ->setMessages($messages) ->setLabels($labels) ->validate(); return $result[$name]; // if you implement ValidatesMany, you will just return $result } }
Note: Custom constraints are considered a part of the Special Constraint Attributes Group (i.e. not allowed to be used with/inside the Shape::class and Compound::class constraints)
Validations
The following table lists all available rules including their Attribute and Method equivalents:
Rules and Aliases
| No. | Rule | Description | Attribute / Method |
|---|---|---|---|
| 001 | Name: nullUsage: null |
Asserts that the input is null. | Attribute: NullConstraint::classMethod: Validation::null() |
| 002 | Name: booleanUsage: boolean |
Asserts that the input is a boolean. | Attribute: Boolean::classMethod: Validation::boolean() |
| 003 | Name: integerUsage: integer |
Asserts that the input is an integer. | Attribute: Integer::classMethod: Validation::integer() |
| 004 | Name: floatUsage: float |
Asserts that the input is a float. | Attribute: FloatConstraint::classMethod: Validation::float() |
| 005 | Name: numericUsage: numeric |
Asserts that the input is numeric. | Attribute: NumericConstraint::classMethod: Validation::numeric() |
| 006 | Name: stringUsage: string |
Asserts that the input is a string. | Attribute: StringConstraint::classMethod: Validation::string() |
| 007 | Name: scalarUsage: scalar |
Asserts that the input is a scalar. | Attribute: Scalar::classMethod: Validation::scalar() |
| 008 | Name: arrayUsage: array |
Asserts that the input is an array. | Attribute: ArrayConstraint::classMethod: Validation::array() |
| 009 | Name: objectUsage: object |
Asserts that the input is an object. | Attribute: ObjectConstraint::classMethod: Validation::object() |
| 010 | Name: callableUsage: callable |
Asserts that the input is a callable. | Attribute: CallableConstraint::classMethod: Validation::callable() |
| 011 | Name: iterableUsage: iterable |
Asserts that the input is an iterable. | Attribute: IterableConstraint::classMethod: Validation::iterable() |
| 012 | Name: countableUsage: countable |
Asserts that the input is a countable. | Attribute: Countable::classMethod: Validation::countable() |
| 013 | Name: resourceUsage: resource |
Asserts that the input is a resource. | Attribute: ResourceConstraint::classMethod: Validation::resource() |
| 014 | Name: typeUsage: type:'["int","float"]' |
Asserts that the input is one of the given types. | Attribute: Type::classMethod: Validation::type(string|array $type) |
| 015 | Name: type.debugUsage: type.debug:string |
Asserts that the input is of the given type using get_debug_type(). | Attribute: TypeDebug::classMethod: Validation::typeDebug(string $type) |
| 016 | Name: alphaUsage: alpha |
Asserts that the input consists of alphabetic characters only. | Attribute: Alpha::classMethod: Validation::alpha() |
| 017 | Name: alnumUsage: alnum |
Asserts that the input consists of alphanumeric characters only. | Attribute: Alnum::classMethod: Validation::alnum() |
| 018 | Name: lowerUsage: lower |
Asserts that the input consists of lowercase characters only. | Attribute: Lower::classMethod: Validation::lower() |
| 019 | Name: upperUsage: upper |
Asserts that the input consists of uppercase characters only. | Attribute: Upper::classMethod: Validation::upper() |
| 020 | Name: cntrlUsage: cntrl |
Asserts that the input consists of control characters only. | Attribute: Cntrl::classMethod: Validation::cntrl() |
| 021 | Name: spaceUsage: space |
Asserts that the input consists of whitespace characters only. | Attribute: Space::classMethod: Validation::space() |
| 022 | Name: punctUsage: punct |
Asserts that the input consists of punctuation characters only. | Attribute: Punct::classMethod: Validation::punct() |
| 023 | Name: graphUsage: graph |
Asserts that the input consists of graphic characters only (characters that create a visible output). | Attribute: Graph::classMethod: Validation::graph() |
| 024 | Name: printUsage: print |
Asserts that the input consists of printable characters only. | Attribute: PrintConstraint::classMethod: Validation::print() |
| 025 | Name: digitUsage: digit |
Asserts that the input consists of a digits only (numeric characters). | Attribute: Digit::classMethod: Validation::digit() |
| 026 | Name: xdigitUsage: xdigit |
Asserts that the input represent hexadecimal digits. | Attribute: Xdigit::classMethod: Validation::xdigit() |
| 027 | Name: booleanLikeUsage: booleanLike |
Asserts that the input is a value that can be parsed as a boolean (TRUE: true, "true", "1", "on", "yes"; FALSE: false, "false", "0", "off", "no", "", null). | Attribute: BooleanLike::classMethod: Validation::booleanLike() |
| 028 | Name: integerLikeUsage: integerLike:0,100 |
Asserts that the input is a value that can be parsed as an integer within the specifed range. | Attribute: IntegerLike::classMethod: Validation::integerLike(int $min = PHP_INT_MIN, int $max = PHP_INT_MAX) |
| 029 | Name: integerLike.allowOctalUsage: integerLike.allowOctal:0,100 |
Asserts that the input is a value that can be parsed as an integer within the specifed range and can be in octal notation. | Attribute: IntegerLikeAllowOctal::classMethod: Validation::integerLikeAllowOctal(int $min = PHP_INT_MIN, int $max = PHP_INT_MAX) |
| 030 | Name: integerLike.allowHexUsage: integerLike.allowHex:0,100 |
Asserts that the input is a value that can be parsed as an integer within the specifed range and can be in hexadecimal notation. | Attribute: IntegerLikeAllowHex::classMethod: Validation::integerLikeAllowHex(int $min = PHP_INT_MIN, int $max = PHP_INT_MAX) |
| 031 | Name: floatLikeUsage: floatLike:1.0,100.0 |
Asserts that the input is a value that can be parsed as a float within the specifed range. | Attribute: FloatLike::classMethod: Validation::floatLike(float $min = PHP_FLOAT_MIN, float $max = PHP_FLOAT_MAX) |
| 032 | Name: floatLike.allowThousandsUsage: floatLike.allowThousands:1.0,100.0 |
Asserts that the input is a value that can be parsed as a float within the specifed range. | Attribute: FloatLikeAllowThousands::classMethod: Validation::floatLikeAllowThousands(float $min = PHP_FLOAT_MIN, float $max = PHP_FLOAT_MAX) |
| 033 | Name: regexpUsage: regexp:"/[a-z]/i" |
Asserts that the input matches a Perl-compatible regular expression. | Attribute: Regexp::classMethod: Validation::regexp(string $pattern) |
| 034 | Name: ipUsage: ip |
Asserts that the input is an IP address. | Attribute: Ip::classMethod: Validation::ip() |
| 035 | Name: ip.v4Usage: ip.v4 |
Asserts that the input is an IPv4 address. | Attribute: IpV4::classMethod: Validation::ipV4() |
| 036 | Name: ip.v6Usage: ip.v6 |
Asserts that the input is an IPv6 address. | Attribute: IpV6::classMethod: Validation::ipV6() |
| 037 | Name: ip.notReservedUsage: ip.notReserved |
Asserts that the input is an IP address not within reserved IPs range. | Attribute: IpNotReserved::classMethod: Validation::ipNotReserved() |
| 038 | Name: ip.notPrivateUsage: ip.notPrivate |
Asserts that the input is an IP address not within private IPs range. | Attribute: IpNotPrivate::classMethod: Validation::ipNotPrivate() |
| 039 | Name: macUsage: mac |
Asserts that the input is a MAC address. | Attribute: Mac::classMethod: Validation::mac() |
| 040 | Name: urlUsage: url |
Asserts that the input is a URL. | Attribute: Url::classMethod: Validation::url() |
| 041 | Name: url.withPathUsage: url.withPath |
Asserts that the input is a URL that contains a path. | Attribute: UrlWithPath::classMethod: Validation::urlWithPath() |
| 042 | Name: url.withQueryUsage: url.withQuery |
Asserts that the input is a URL that contains a query. | Attribute: UrlWithQuery::classMethod: Validation::urlWithQuery() |
| 043 | Name: emailUsage: email |
Asserts that the input is an email address. | Attribute: Email::classMethod: Validation::email() |
| 044 | Name: email.withUnicodeUsage: email.withUnicode |
Asserts that the input is an email address (unicode allowed). | Attribute: EmailWithUnicode::classMethod: Validation::emailWithUnicode() |
| 045 | Name: domainUsage: domain |
Asserts that the input is a domain. | Attribute: Domain::classMethod: Validation::domain() |
| 046 | Name: domain.isActiveUsage: domain.isActive |
Asserts that the input is an active domain. Works with domains and emails. | Attribute: DomainIsActive::classMethod: Validation::domainIsActive() |
| 047 | Name: fileUsage: file |
Asserts that the input is a file (can be a file, a link, or a directory). | Attribute: File::classMethod: Validation::file() |
| 048 | Name: file.isFileUsage: file.isFile |
Asserts that the input is a file. | Attribute: FileIsFile::classMethod: Validation::fileIsFile() |
| 049 | Name: file.isLinkUsage: file.isLink |
Asserts that the input is a link. | Attribute: FileIsLink::classMethod: Validation::fileIsLink() |
| 050 | Name: file.isDirectoryUsage: file.isDirectory |
Asserts that the input is a directory. | Attribute: FileIsDirectory::classMethod: Validation::fileIsDirectory() |
| 051 | Name: file.isExecutableUsage: file.isExecutable |
Asserts that the input is a file and is executable. | Attribute: FileIsExecutable::classMethod: Validation::fileIsExecutable() |
| 052 | Name: file.isWritableUsage: file.isWritable |
Asserts that the input is a file and is writable. | Attribute: FileIsWritable::classMethod: Validation::fileIsWritable() |
| 053 | Name: file.isReadableUsage: file.isReadable |
Asserts that the input is a file and is readable. | Attribute: FileIsReadable::classMethod: Validation::fileIsReadable() |
| 054 | Name: file.isUploadedUsage: file.isUploaded |
Asserts that the input is a file that is uploaded via HTTP POST. | Attribute: FileIsUploaded::classMethod: Validation::fileIsUploaded() |
| 055 | Name: file.sizeUsage: file.size:1024 |
Asserts that the input is a file and the size is equal to the given size in bytes. | Attribute: FileSize::classMethod: Validation::fileSize(int $sizeInBytes) |
| 056 | Name: file.size.lteUsage: file.size.lte:1024 |
Asserts that the input is a file and the size is less than or equal to the given size in bytes. | Attribute: FileSizeLte::classMethod: Validation::fileSizeLte(int $sizeInBytes) |
| 057 | Name: file.size.gteUsage: file.size.gte:1024 |
Asserts that the input is a file and the size is greater than or equal to the given size in bytes. | Attribute: FileSizeGte::classMethod: Validation::fileSizeGte(int $sizeInBytes) |
| 058 | Name: file.dirnameUsage: file.dirname:/path/to/dir |
Asserts that the input is a file and its dirname is equal to the given dirname. | Attribute: FileDirname::classMethod: Validation::fileDirname(string $dirname) |
| 059 | Name: file.basenameUsage: file.basename:file.ext |
Asserts that the input is a file and its basename is equal to the given basename. | Attribute: FileBasename::classMethod: Validation::fileBasename(string $basename) |
| 060 | Name: file.filenameUsage: file.filename:file |
Asserts that the input is a file and its filename is equal to the given filename. | Attribute: FileFilename::classMethod: Validation::fileFilename(string $filename) |
| 061 | Name: file.extensionUsage: file.extension:ext |
Asserts that the input is a file and its extension is equal to the given extension. | Attribute: FileExtension::classMethod: Validation::fileExtension(string $extension) |
| 062 | Name: file.mimeUsage: file.mime:text/plain |
Asserts that the input is a file and its MIME type is one of the given MIME types. | Attribute: FileMime::classMethod: Validation::fileMime(string|array $mine) |
| 063 | Name: imageUsage: image |
Asserts that the input is an image file (jpg, jpeg, png, gif, bmp, svg, or webp). | Attribute: Image::classMethod: Validation::image() |
| 064 | Name: image.widthUsage: image.width:1920 |
Asserts that the input is an image and its width is equal to the given width in pixels. | Attribute: ImageWidth::classMethod: Validation::imageWidth(int $width) |
| 065 | Name: image.width.lteUsage: image.width.lte:1920 |
Asserts that the input is an image and its width is less than or equal to the given width in pixels. | Attribute: ImageWidthLte::classMethod: Validation::imageWidthLte(int $width) |
| 066 | Name: image.width.gteUsage: image.width.gte:1920 |
Asserts that the input is an image and its width is greater than or equal to the given width in pixels. | Attribute: ImageWidthGte::classMethod: Validation::imageWidthGte(int $width) |
| 067 | Name: image.heightUsage: image.height:1080 |
Asserts that the input is an image and its height is equal to the given height in pixels. | Attribute: ImageHeight::classMethod: Validation::imageHeight(int $height) |
| 068 | Name: image.height.lteUsage: image.height.lte:1080 |
Asserts that the input is an image and its height is less than or equal to the given height in pixels. | Attribute: ImageHeightLte::classMethod: Validation::imageHeightLte(int $height) |
| 069 | Name: image.height.gteUsage: image.height.gte:1080 |
Asserts that the input is an image and its height is greater than or equal to the given height in pixels. | Attribute: ImageHeightGte::classMethod: Validation::imageHeightGte(int $height) |
| 070 | Name: image.dimensionsUsage: image.dimensions:1920,1080,== |
Asserts that the input is an image and its dimensions are less than, equal to, or greater than the given width and height in pixels. | Attribute: ImageDimensions::classMethod: Validation::imageDimensions(int $width, int $height, string $operator = '==') |
| 071 | Name: image.ratioUsage: image.ratio:16:9 |
Asserts that the input is an image and its aspect ratio is equal to the given ratio (ratio must be specified as fraction like "16/9"). | Attribute: ImageRatio::classMethod: Validation::imageRatio(string $ratio) |
| 072 | Name: ifUsage: if:7,7,== |
Checks the condition between the first argument and the second argument, the condition operator can also be specified as the third argument. | Attribute: IfConstraint::classMethod: Validation::if(mixed $actual, mixed $expected = true, string $operator = '==') |
| 073 | Name: if.eqUsage: if.eq:3,3 |
Checks the condition between the first argument and the second argument, the condition operator is "==". | Attribute: IfEq::classMethod: Validation::ifEq(mixed $actual, mixed $expected) |
| 074 | Name: if.neqUsage: if.neq:1,2 |
Checks the condition between the first argument and the second argument, the condition operator is "!=". | Attribute: IfNeq::classMethod: Validation::ifNeq(mixed $actual, mixed $expected) |
| 075 | Name: if.idUsage: if.id:3,3 |
Checks the condition between the first argument and the second argument, the condition operator is "===". | Attribute: IfId::classMethod: Validation::ifId(mixed $actual, mixed $expected) |
| 076 | Name: if.nidUsage: if.nid:1,2 |
Checks the condition between the first argument and the second argument, the condition operator is "!==". | Attribute: IfNid::classMethod: Validation::ifNid(mixed $actual, mixed $expected) |
| 077 | Name: if.gtUsage: if.gt:2,1 |
Checks the condition between the first argument and the second argument, the condition operator is ">". | Attribute: IfGt::classMethod: Validation::ifGt(mixed $actual, mixed $expected) |
| 078 | Name: if.gteUsage: if.gte:2,2 |
Checks the condition between the first argument and the second argument, the condition operator is ">=". | Attribute: IfGte::classMethod: Validation::ifGte(mixed $actual, mixed $expected) |
| 079 | Name: if.ltUsage: if.lt:1,2 |
Checks the condition between the first argument and the second argument, the condition operator is "<". | Attribute: IfLt::classMethod: Validation::ifLt(mixed $actual, mixed $expected) |
| 080 | Name: if.lteUsage: if.lte:1,2 |
Checks the condition between the first argument and the second argument, the condition operator is "<=". | Attribute: IfLte::classMethod: Validation::ifLte(mixed $actual, mixed $expected) |
| 081 | Name: emptyUsage: empty |
Asserts that the input is empty using empty() language construct (is blank, i.e. empty string, empty array, false, null, or 0). | Attribute: EmptyConstraint::classMethod: Validation::empty() |
| 082 | Name: requiredUsage: required |
Asserts that the input is required (is not blank, i.e. not a empty string or null). | Attribute: Required::classMethod: Validation::required() |
| 083 | Name: allowedUsage: allowed |
Asserts that the input is allowed (can be empty or have any value, null and empty string are considered valid values). | Attribute: Allowed::classMethod: Validation::allowed() |
| 084 | Name: forbiddenUsage: forbidden |
Asserts that the input is forbidden (is null or not present). | Attribute: Forbidden::classMethod: Validation::forbidden() |
| 085 | Name: acceptedUsage: accepted |
Asserts that the input is accepted (equals: "on", "yes", "yeah", "yep", "yo", "ok", "okay", "aye", 1 or "1", true or "true") note that strings are treated in a case-insensitive manner. | Attribute: Accepted::classMethod: Validation::accepted() |
| 086 | Name: declinedUsage: declined |
Asserts that the input is declined (equals: "off", "no", "not", "nope", "neh", "nay", 0 or "0", false or "false") note that strings are treated in a case-insensitive manner. | Attribute: Declined::classMethod: Validation::declined() |
| 087 | Name: bitUsage: bit |
Asserts that the input is bit (equals: 1 or "1", true; 0 or "0", false). | Attribute: Bit::classMethod: Validation::bit() |
| 088 | Name: bit.isOnUsage: bit.isOn |
Asserts that the input is a turned on bit (equals: true, 1 or "1"). | Attribute: BitIsOn::classMethod: Validation::bitIsOn() |
| 089 | Name: bit.isOffUsage: bit.isOff |
Asserts that the input is a turned off bit (equals: false, 0 or "0"). | Attribute: BitIsOff::classMethod: Validation::bitIsOff() |
| 090 | Name: equalsUsage: equals:value |
Asserts that the input is equal to the given value. Works with scalar types and null. Comparison operator is "==". | Attribute: Equals::classMethod: Validation::equals(string|int|float|bool|null $value) |
| 091 | Name: matchesUsage: matches:'"/^[a-zA-Z0-9]+$/"' |
Asserts that the input matches the given pattern. Works with strings only. | Attribute: Matches::classMethod: Validation::matches(string $pattern) |
| 092 | Name: inUsage: in:val1,val2,... |
Asserts that the input is in the given values. Works with scalar types and null. | Attribute: In::classMethod: Validation::in(string|int|float|bool|null ...$values) |
| 093 | Name: countUsage: count:3 |
Asserts that the input count is equal to the given value. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count). | Attribute: Count::classMethod: Validation::count(int $count) |
| 094 | Name: minUsage: min:3 |
Asserts that the input count is greater than or equal to the given value. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count). | Attribute: Min::classMethod: Validation::min(int|float $count) |
| 095 | Name: maxUsage: max:3 |
Asserts that the input count is less than or equal to the given value. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count). | Attribute: Max::classMethod: Validation::max(int|float $count) |
| 096 | Name: betweenUsage: between:3,7 |
Asserts that the input count is between the given values. Works with all data types (null: 0; boolean: 0 or 1; float/integer: number value; string: characters count; array/countable: elements count; object: accessible properties count). | Attribute: Between::classMethod: Validation::between(int|float $min, int|float $max) |
| 097 | Name: number.isPositiveUsage: number.isPositive |
Asserts that the input is a positive number. | Attribute: NumberIsPositive::classMethod: Validation::numberIsPositive() |
| 098 | Name: number.isNegativeUsage: number.isNegative |
Asserts that the input is a negative number. | Attribute: NumberIsNegative::classMethod: Validation::numberIsNegative() |
| 099 | Name: number.isEvenUsage: number.isEven |
Asserts that the input is an even number. | Attribute: NumberIsEven::classMethod: Validation::numberIsEven() |
| 100 | Name: number.isOddUsage: number.isOdd |
Asserts that the input is an odd number. | Attribute: NumberIsOdd::classMethod: Validation::numberIsOdd() |
| 101 | Name: number.isMultipleOfUsage: number.isMultipleOf:3 |
Asserts that the input is a multiple of the given number. | Attribute: NumberIsMultipleOf::classMethod: Validation::numberIsMultipleOf(float $number) |
| 102 | Name: number.isFiniteUsage: number.isFinite |
Asserts that the input is a finite number. | Attribute: NumberIsFinite::classMethod: Validation::numberIsFinite() |
| 103 | Name: number.isInfiniteUsage: number.isInfinite |
Asserts that the input is an infinite number. | Attribute: NumberIsInfinite::classMethod: Validation::numberIsInfinite() |
| 104 | Name: number.isNanUsage: number.isNan |
Asserts that the input is a not a number. | Attribute: NumberIsNan::classMethod: Validation::numberIsNan() |
| 105 | Name: string.charsetUsage: string.charset:UTF-8 |
Asserts that the input is encoded in one of the given charsets (aliases included). The check is done in a case-sensitive manner. | Attribute: StringCharset::classMethod: Validation::stringCharset(string|array $charset) |
| 106 | Name: string.containsUsage: string.contains:substring |
Asserts that the input contains the given substring. A second boolean argument can be specified to enable strict mode (case-sensitive). | Attribute: StringContains::classMethod: Validation::stringContains(string $substring, bool $strict = false) |
| 107 | Name: string.startsWithUsage: string.startsWith:substring,1 |
Asserts that the input starts with the given substring. A second boolean argument can be specified to enable strict mode (case-sensitive). | Attribute: StringStartsWith::classMethod: Validation::stringStartsWith(string $substring, bool $strict = false) |
| 108 | Name: string.endsWithUsage: string.endsWith:substring,0 |
Asserts that the input ends with the given substring. A second boolean argument can be specified to enable strict mode (case-sensitive). | Attribute: StringEndsWith::classMethod: Validation::stringEndsWith(string $substring, bool $strict = false) |
| 109 | Name: string.lengthUsage: string.length:3 |
Asserts that the input is a string that is exactly the given length. | Attribute: StringLength::classMethod: Validation::stringLength(int $length) |
| 110 | Name: string.wordsCountUsage: string.wordsCount:3 |
Asserts that the input is a string containing exactly the given count of words. | Attribute: StringWordsCount::classMethod: Validation::stringWordsCount(int $count) |
| 111 | Name: array.hasKeyUsage: array.hasKey:key |
Asserts that the input array has the given key. | Attribute: ArrayHasKey::classMethod: Validation::arrayHasKey(string|int $key) |
| 112 | Name: array.hasValueUsage: array.hasValue:value |
Asserts that the input array contains the given value. Works with scalar types. | Attribute: ArrayHasValue::classMethod: Validation::arrayHasValue(mixed $value) |
| 113 | Name: array.hasDistinctUsage: array.hasDistinct:key |
Asserts that the input is a multidimensional array that contains distinct values of the given key. | Attribute: ArrayHasDistinct::classMethod: Validation::arrayHasDistinct(string|int $key) |
| 114 | Name: array.isAssociativeUsage: array.isAssociative |
Asserts that the input is an associative array. | Attribute: ArrayIsAssociative::classMethod: Validation::arrayIsAssociative() |
| 115 | Name: array.isSequentialUsage: array.isSequential |
Asserts that the input is a sequential array. | Attribute: ArrayIsSequential::classMethod: Validation::arrayIsSequential() |
| 116 | Name: array.isUniqueUsage: array.isUnique |
Asserts that the input array contains unique values. Works only with one-dimensional arrays. | Attribute: ArrayIsUnique::classMethod: Validation::arrayIsUnique() |
| 117 | Name: array.subsetUsage: array.subset:'{"a":1,"b":2}' |
Asserts that the input is an array that contains the given subset. Note that this check applies only to the first dimension of the array. | Attribute: ArraySubset::classMethod: Validation::arraySubset(array $subset) |
| 118 | Name: object.hasPropertyUsage: object.hasProperty:property |
Asserts that the input has the given property. | Attribute: ObjectHasProperty::classMethod: Validation::objectHasProperty(string $property) |
| 119 | Name: object.hasMethodUsage: object.hasMethod:method |
Asserts that the input has the given method. | Attribute: ObjectHasMethod::classMethod: Validation::objectHasMethod(string $method) |
| 120 | Name: object.isStringableUsage: object.isStringable |
Asserts that the input implements __toString() method. | Attribute: ObjectIsStringable::classMethod: Validation::objectIsStringable() |
| 121 | Name: object.isInstanceOfUsage: object.isInstanceOf:\Namespace\Class |
Asserts that the input is an instance of the given class. | Attribute: ObjectIsInstanceOf::classMethod: Validation::objectIsInstanceOf(string $classFQN) |
| 122 | Name: object.isSubclassOfUsage: object.isSubclassOf:\Namespace\Class |
Asserts that the input is a subclass of the given class. | Attribute: ObjectIsSubclassOf::classMethod: Validation::objectIsSubclassOf(string $classFQN) |
| 123 | Name: serializedUsage: serialized |
Asserts that the input is a valid PHP serialized data. | Attribute: Serialized::classMethod: Validation::serialized() |
| 124 | Name: jsonUsage: json |
Asserts that the input is a valid JSON. | Attribute: Json::classMethod: Validation::json() |
| 125 | Name: base64Usage: base64 |
Asserts that the input is a valid Base64 encoded string. | Attribute: Base64::classMethod: Validation::base64() |
| 126 | Name: xmlUsage: xml |
Asserts that the input is a valid XML. | Attribute: Xml::classMethod: Validation::xml() |
| 127 | Name: localeUsage: locale |
Asserts that the input is a valid locale identifier (default: [ISO 639-1] or [ISO 639-1]_[ISO 3166-1 alpha-2], case-insensitive, input is canonicalized before checking (dashes to underscores, no dots or charset); strict: [ISO 639-1] or [ISO 639-1]_[ISO 3166-1 alpha-2], case-sensitive without canonicalization. | Attribute: Locale::classMethod: Validation::locale(bool $strict = false) |
| 128 | Name: languageUsage: language |
Asserts that the input is a valid language code (default: "ISO 639-1"; long: "ISO 639-2/T"). | Attribute: Language::classMethod: Validation::language(bool $long = false) |
| 129 | Name: countryUsage: country |
Asserts that the input is a valid country code (default: "ISO 3166-1 alpha-2"; long: "ISO 3166-1 alpha-3"). | Attribute: Country::classMethod: Validation::country(bool $long = false) |
| 130 | Name: timezoneUsage: timezone |
Asserts that the input is a valid timezone identifier (default: case-insensitive; strict: case-sensitive). | Attribute: Timezone::classMethod: Validation::timezone(bool $strict = false) |
| 131 | Name: datetimeUsage: datetime |
Asserts that the input is a valid datetime string/object. | Attribute: Datetime::classMethod: Validation::datetime() |
| 132 | Name: datetime.eqUsage: datetime.eq:"2015-01-01" |
Asserts that the input is equal to the given datetime string. | Attribute: DatetimeEq::classMethod: Validation::datetimeEq(string $datetime) |
| 133 | Name: datetime.ltUsage: datetime.lt:tomorrow |
Asserts that the input is a datetime string/object less than (before) the given datetime string. | Attribute: DatetimeLt::classMethod: Validation::datetimeLt(string $datetime) |
| 134 | Name: datetime.lteUsage: datetime.lte:tomorrow |
Asserts that the input is a datetime string/object less than (before) or equal to the given datetime string. | Attribute: DatetimeLte::classMethod: Validation::datetimeLte(string $datetime) |
| 135 | Name: datetime.gtUsage: datetime.gt:today |
Asserts that the input is a datetime string/object greater than (after) the given datetime string. | Attribute: DatetimeGt::classMethod: Validation::datetimeGt(string $datetime) |
| 136 | Name: datetime.gteUsage: datetime.gte:today |
Asserts that the input is a datetime string/object greater than (after) or equal to the given datetime string. | Attribute: DatetimeGte::classMethod: Validation::datetimeGte(string $datetime) |
| 137 | Name: datetime.birthdayUsage: datetime.birthday |
Asserts that the input is a datetime string/object that has birthday today. Input should preferably be in "YYYY-MM-DD" format. | Attribute: DatetimeBirthday::classMethod: Validation::datetimeBirthday() |
| 138 | Name: datetime.formatUsage: datetime.format:"Y-m-d H:i:s" |
Asserts that the input is a valid date/time with the given format. | Attribute: DatetimeFormat::classMethod: Validation::datetimeFormat(string $format) |
| 139 | Name: datetime.format.globalUsage: datetime.format.global |
Asserts that the input looks like a valid global datetime string as defined in the HTML5 specification. | Attribute: DatetimeFormatGlobal::classMethod: Validation::datetimeFormatGlobal() |
| 140 | Name: datetime.format.localUsage: datetime.format.local |
Asserts that the input looks like a valid local datetime string as defined in the HTML5 specification. | Attribute: DatetimeFormatLocal::classMethod: Validation::datetimeFormatLocal() |
| 141 | Name: datestampUsage: datestamp |
Asserts that the input looks like a human datestamp, DMY or MDY format, separated with dot, dash, or slash. | Attribute: Datestamp::classMethod: Validation::datestamp() |
| 142 | Name: datestamp.ymdUsage: datestamp.ymd |
Asserts that the input looks like a human YMD-formatted datestamp, separated with dot, dash, or slash. | Attribute: DatestampYmd::classMethod: Validation::datestampYmd() |
| 143 | Name: datestamp.dmyUsage: datestamp.dmy |
Asserts that the input looks like a human DMY-formatted datestamp, separated with dot, dash, or slash. | Attribute: DatestampDmy::classMethod: Validation::datestampDmy() |
| 144 | Name: datestamp.mdyUsage: datestamp.mdy |
Asserts that the input looks like a human MDY-formatted datestamp, separated with dot, dash, or slash. | Attribute: DatestampMdy::classMethod: Validation::datestampMdy() |
| 145 | Name: timestampUsage: timestamp |
Asserts that the input looks like a human timestamp, 24 or 12 hours format with or without seconds. | Attribute: Timestamp::classMethod: Validation::timestamp() |
| 146 | Name: timestamp.12Usage: timestamp.12 |
Asserts that the input looks like a human timestamp, 12 hours format with or without seconds and optional AM/PM. | Attribute: Timestamp12::classMethod: Validation::timestamp12() |
| 147 | Name: timestamp.hmsUsage: timestamp.hms |
Asserts that the input looks like a human timestamp, 24 or 12 hours format with seconds. | Attribute: TimestampHms::classMethod: Validation::timestampHms() |
| 148 | Name: timestamp.hmUsage: timestamp.hm |
Asserts that the input looks like a human timestamp, 24 or 12 hours format without seconds. | Attribute: TimestampHm::classMethod: Validation::timestampHm() |
| 149 | Name: timestamp.msUsage: timestamp.ms |
Asserts that the input looks like a human timestamp, containing minutes and seconds only. | Attribute: TimestampMs::classMethod: Validation::timestampMs() |
| 150 | Name: calender.dayUsage: calender.day |
Asserts that the input looks like a calendar dayin shot or long format ("Mon" or "Monday"). | Attribute: CalenderDay::classMethod: Validation::calenderDay() |
| 151 | Name: calender.monthUsage: calender.month |
Asserts that the input looks like a calendar month in shot or long format ("Jan" or "January"). | Attribute: CalenderMonth::classMethod: Validation::calenderMonth() |
| 152 | Name: usernameUsage: username |
Asserts that the input is a valid username (between 4-32 characters, consists of letters in any case, optionally numbers, optionally one of the following characters "-_." (not consecutive), and must always start with a letter and end with a letter or number). | Attribute: Username::classMethod: Validation::username() |
| 153 | Name: passwordUsage: password |
Asserts that the input is a valid password (minimum 8 characters, consists of at least one small letter and one capital letter, at least one number, at least one special character, and optionally a space). | Attribute: Password::classMethod: Validation::password() |
| 154 | Name: uuidUsage: uuid |
Asserts that the input is a valid UUID. The version (v1/v2/v3/v4/v5) can be specifed to narrow the pattern. | Attribute: Uuid::classMethod: Validation::uuid(string|int|null $version = null) |
| 155 | Name: asciiUsage: ascii |
Asserts that the input is a string containing only ASCII characters (ASCII compliant string). | Attribute: Ascii::classMethod: Validation::ascii() |
| 156 | Name: slugUsage: slug |
Asserts that the input is a valid slug. | Attribute: Slug::classMethod: Validation::slug() |
| 157 | Name: metaUsage: meta |
Asserts that the input is a string containing only meta characters (special characters) (i.e. "@, #, $, ...").. | Attribute: Meta::classMethod: Validation::meta() |
| 158 | Name: textUsage: text |
Asserts that the input is a string containing letters and punctuation from any language. | Attribute: Text::classMethod: Validation::text() |
| 159 | Name: wordsUsage: words |
Asserts that the input is a string containing only words and spaces without any other character. | Attribute: Words::classMethod: Validation::words() |
| 160 | Name: spacelessUsage: spaceless |
Asserts that the input is a string containing no whitespace characters. | Attribute: Spaceless::classMethod: Validation::spaceless() |
| 161 | Name: emojiUsage: emoji |
Asserts that the input contains an emoji. | Attribute: Emoji::classMethod: Validation::emoji() |
| 162 | Name: romanUsage: roman |
Asserts that the input is a valid roman number. | Attribute: Roman::classMethod: Validation::roman() |
| 163 | Name: phoneUsage: phone |
Asserts that the input is a valid phone number (supports: North America, Europe and most Asian and Middle East countries). | Attribute: Phone::classMethod: Validation::phone() |
| 164 | Name: geolocationUsage: geolocation |
Asserts that the input is a valid geolocation (latitude and longitude coordinates combination). | Attribute: Geolocation::classMethod: Validation::geolocation() |
| 165 | Name: versionUsage: version |
Asserts that the input is a valid semantic version number. | Attribute: Version::classMethod: Validation::version() |
| 166 | Name: amountUsage: amount |
Asserts that the input contains only numbers, an optional decimal point (comma or dot), and an optional minus (used for amounts of money for example). | Attribute: Amount::classMethod: Validation::amount() |
| 167 | Name: amount.dollarUsage: amount.dollar |
Asserts that the input is a validly formatted amount of USD, where decimal point and thousands separator are optional. | Attribute: AmountDollar::classMethod: Validation::amountDollar() |
| 168 | Name: amount.euroUsage: amount.euro |
Asserts that the input is a validly formatted amount of EUR, where decimal point and thousands separator are optional. | Attribute: AmountEuro::classMethod: Validation::amountEuro() |
| 169 | Name: colorUsage: color |
Asserts that the input is a valid CSS color (Keyword "loose", HEX, HEX-Alpha, RGB, RGBA, RGB "new syntax", HSL, HSLA, HSL "new syntax"). | Attribute: Color::classMethod: Validation::color() |
| 170 | Name: color.hexUsage: color.hex |
Asserts that the input is a valid CSS HEX color. | Attribute: ColorHex::classMethod: Validation::colorHex() |
| 171 | Name: color.hexShortUsage: color.hexShort |
Asserts that the input is a valid CSS 3-Char-HEX color. | Attribute: ColorHexShort::classMethod: Validation::colorHexShort() |
| 172 | Name: color.hexLongUsage: color.hexLong |
Asserts that the input is a valid CSS 6-Char-HEX color. | Attribute: ColorHexLong::classMethod: Validation::colorHexLong() |
| 173 | Name: color.hexAlphaUsage: color.hexAlpha |
Asserts that the input is a valid CSS HEX-Alpha (4 or 8 Chars) color. | Attribute: ColorHexAlpha::classMethod: Validation::colorHexAlpha() |
| 174 | Name: color.rgbUsage: color.rgb |
Asserts that the input is a valid CSS RGB color. | Attribute: ColorRgb::classMethod: Validation::colorRgb() |
| 175 | Name: color.rgbaUsage: color.rgba |
Asserts that the input is a valid CSS RGBA color. | Attribute: ColorRgba::classMethod: Validation::colorRgba() |
| 176 | Name: color.rgb.newUsage: color.rgb.new |
Asserts that the input is a valid CSS4 RGB color. | Attribute: ColorRgbNew::classMethod: Validation::colorRgbNew() |
| 177 | Name: color.hslUsage: color.hsl |
Asserts that the input is a valid CSS HSL color. | Attribute: ColorHsl::classMethod: Validation::colorHsl() |
| 178 | Name: color.hslaUsage: color.hsla |
Asserts that the input is a valid CSS HSLA color. | Attribute: ColorHsla::classMethod: Validation::colorHsla() |
| 179 | Name: color.hsl.newUsage: color.hsl.new |
Asserts that the input is a valid CSS4 HSL color. | Attribute: ColorHslNew::classMethod: Validation::colorHslNew() |
| 180 | Name: color.keywordUsage: color.keyword |
Asserts that the input is a valid CSS keyword color (strict, as in the CSS specification). | Attribute: ColorKeyword::classMethod: Validation::colorKeyword() |
| 181 | Name: ssnUsage: ssn |
Asserts that the input is a valid SSN (US Social Security Number). | Attribute: Ssn::classMethod: Validation::ssn() |
| 182 | Name: sinUsage: sin |
Asserts that the input is a valid SIN (CA Social Insurance Number). | Attribute: Sin::classMethod: Validation::sin() |
| 183 | Name: ninoUsage: nino |
Asserts that the input is a valid NINO (UK National Insurance Number). | Attribute: Nino::classMethod: Validation::nino() |
| 184 | Name: vinUsage: vin |
Asserts that the input is a valid VIN (Vehicle Identification Number). | Attribute: Vin::classMethod: Validation::vin() |
| 185 | Name: issnUsage: issn |
Asserts that the input is a valid ISSN (International Standard Serial Number). | Attribute: Issn::classMethod: Validation::issn() |
| 186 | Name: isinUsage: isin |
Asserts that the input is a valid ISIN (International Securities Identification Number). | Attribute: Isin::classMethod: Validation::isin() |
| 187 | Name: isbnUsage: isbn |
Asserts that the input is a valid ISBN (International Standard Book Number). The type (10/13) can be specifed to narrow the pattern. | Attribute: Isbn::classMethod: Validation::isbn(string|int|null $type = null) |
| 188 | Name: imeiUsage: imei |
Asserts that the input is a valid IMEI (International Mobile Station Equipment Identity Number). | Attribute: Imei::classMethod: Validation::imei() |
| 189 | Name: imei.svUsage: imei.sv |
Asserts that the input is a valid IMEI-SV (International Mobile Station Equipment Identity and Software Version Number). | Attribute: ImeiSv::classMethod: Validation::imeiSv() |
| 190 | Name: meidUsage: meid |
Asserts that the input is a valid MEID (Mobile Equipment Identifier). | Attribute: Meid::classMethod: Validation::meid() |
| 191 | Name: esnUsage: esn |
Asserts that the input is a valid ESN (Electronic Serial Number). | Attribute: Esn::classMethod: Validation::esn() |
| 192 | Name: currencyUsage: currency |
Asserts that the input is a valid currency code (default: "ISO 4217 alpha"; numeric: "ISO 4217 numeric"). | Attribute: Currency::classMethod: Validation::currency(bool $numeric = false) |
| 193 | Name: currency.nameUsage: currency.name |
Asserts that the input is a valid currency name (as in ISO 4217). | Attribute: CurrencyName::classMethod: Validation::currencyName() |
| 194 | Name: creditcardUsage: creditcard |
Asserts that the input is a valid credit card number, balanced spaces and/or dashes are allowed. | Attribute: Creditcard::classMethod: Validation::creditcard() |
| 195 | Name: creditcard.visaUsage: creditcard.visa |
Asserts that the input is a valid Visa credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardVisa::classMethod: Validation::creditcardVisa() |
| 196 | Name: creditcard.mastercardUsage: creditcard.mastercard |
Asserts that the input is a valid Mastercard credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardMastercard::classMethod: Validation::creditcardMastercard() |
| 197 | Name: creditcard.discoverUsage: creditcard.discover |
Asserts that the input is a valid Discover credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardDiscover::classMethod: Validation::creditcardDiscover() |
| 198 | Name: creditcard.americanExpressUsage: creditcard.americanExpress |
Asserts that the input is a valid American Express credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardAmericanExpress::classMethod: Validation::creditcardAmericanExpress() |
| 199 | Name: creditcard.dinersClubUsage: creditcard.dinersClub |
Asserts that the input is a valid Diners Club credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardDinersClub::classMethod: Validation::creditcardDinersClub() |
| 200 | Name: creditcard.jcbUsage: creditcard.jcb |
Asserts that the input is a valid JCB credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardJcb::classMethod: Validation::creditcardJcb() |
| 201 | Name: creditcard.maestroUsage: creditcard.maestro |
Asserts that the input is a valid Maestro credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardMaestro::classMethod: Validation::creditcardMaestro() |
| 202 | Name: creditcard.chinaUnionPayUsage: creditcard.chinaUnionPay |
Asserts that the input is a valid China UnionPay credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardChinaUnionPay::classMethod: Validation::creditcardChinaUnionPay() |
| 203 | Name: creditcard.instaPaymentUsage: creditcard.instaPayment |
Asserts that the input is a valid InstaPayment credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardInstaPayment::classMethod: Validation::creditcardInstaPayment() |
| 204 | Name: creditcard.laserUsage: creditcard.laser |
Asserts that the input is a valid Laser credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardLaser::classMethod: Validation::creditcardLaser() |
| 205 | Name: creditcard.uatpUsage: creditcard.uatp |
Asserts that the input is a valid UATP credit card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardUatp::classMethod: Validation::creditcardUatp() |
| 206 | Name: creditcard.mirUsage: creditcard.mir |
Asserts that the input is a valid MIR Payment System card number, balanced spaces and/or dashes are allowed. | Attribute: CreditcardMir::classMethod: Validation::creditcardMir() |
| 207 | Name: cvvUsage: cvv |
Asserts that the input is a valid CVV (Card Security Code). | Attribute: Cvv::classMethod: Validation::cvv() |
| 208 | Name: bicUsage: bic |
Asserts that the input is a valid BIC (Bank Identifier Code). | Attribute: Bic::classMethod: Validation::bic() |
| 209 | Name: ibanUsage: iban:IQ |
Asserts that the input is a valid IBAN (International Bank Account Number). The "ISO 3166-1 alpha-2" country code can be specifed to narrow the pattern. | Attribute: Iban::classMethod: Validation::iban(?string $country = null) |
| 210 | Name: luhnUsage: luhn |
Asserts that the input passes the Luhn Algorithm check. This rule is mostly used in conjunction with other rules like credit card numbers and identifiers to further check the validity of the subject. | Attribute: Luhn::classMethod: Validation::luhn() |
| 211 | Name: php.keywordUsage: php.keyword |
Asserts that the input is a PHP language keyword. | Attribute: PhpKeyword::classMethod: Validation::phpKeyword() |
| 212 | Name: php.reservedUsage: php.reserved |
Asserts that the input is a PHP language reserved word. | Attribute: PhpReserved::classMethod: Validation::phpReserved() |
| 213 | Name: php.reserved.extraUsage: php.reserved.extra |
Asserts that the input is a PHP language reserved word including soft reserved words. | Attribute: PhpReservedExtra::classMethod: Validation::phpReservedExtra() |
| 214 | Name: regexUsage: regex |
Asserts that the input is a valid regular expression. | Attribute: Regex::classMethod: Validation::regex() |
| 215 | Name: boolUsage: see boolean |
Alias, refer to boolean for the full description. |
Attribute: BoolConstraint::classMethod: Validation::bool() |
| 216 | Name: intUsage: see integer |
Alias, refer to integer for the full description. |
Attribute: IntConstraint::classMethod: Validation::int() |
| 217 | Name: longUsage: see integer |
Alias, refer to integer for the full description. |
Attribute: Long::classMethod: Validation::long() |
| 218 | Name: doubleUsage: see float |
Alias, refer to float for the full description. |
Attribute: Double::classMethod: Validation::double() |
| 219 | Name: realUsage: see float |
Alias, refer to float for the full description. |
Attribute: Real::classMethod: Validation::real() |
| 220 | Name: strUsage: see string |
Alias, refer to string for the full description. |
Attribute: Str::classMethod: Validation::str() |
| 221 | Name: arrUsage: see array |
Alias, refer to array for the full description. |
Attribute: Arr::classMethod: Validation::arr() |
| 222 | Name: objUsage: see object |
Alias, refer to object for the full description. |
Attribute: Obj::classMethod: Validation::obj() |
| 223 | Name: streamUsage: see resource |
Alias, refer to resource for the full description. |
Attribute: Stream::classMethod: Validation::stream() |
| 224 | Name: assertUsage: see if |
Alias, refer to if for the full description. |
Attribute: Assert::classMethod: Validation::assert(mixed $actual, mixed $expected = true, string $operator = '==') |
| 225 | Name: assert.equalsUsage: see if.eq |
Alias, refer to if.eq for the full description. |
Attribute: AssertEquals::classMethod: Validation::assertEquals(mixed $actual, mixed $expected) |
| 226 | Name: assert.notEqualsUsage: see if.neq |
Alias, refer to if.neq for the full description. |
Attribute: AssertNotEquals::classMethod: Validation::assertNotEquals(mixed $actual, mixed $expected) |
| 227 | Name: assert.greaterThanUsage: see if.gt |
Alias, refer to if.gt for the full description. |
Attribute: AssertGreaterThan::classMethod: Validation::assertGreaterThan(mixed $actual, mixed $expected) |
| 228 | Name: assert.greaterThanOrEqualsUsage: see if.gte |
Alias, refer to if.gte for the full description. |
Attribute: AssertGreaterThanOrEquals::classMethod: Validation::assertGreaterThanOrEquals(mixed $actual, mixed $expected) |
| 229 | Name: assert.lessThanUsage: see if.lt |
Alias, refer to if.lt for the full description. |
Attribute: AssertLessThan::classMethod: Validation::assertLessThan(mixed $actual, mixed $expected) |
| 230 | Name: assert.lessThanOrEqualsUsage: see if.lte |
Alias, refer to if.lte for the full description. |
Attribute: AssertLessThanOrEquals::classMethod: Validation::assertLessThanOrEquals(mixed $actual, mixed $expected) |
| 231 | Name: blankUsage: see empty |
Alias, refer to empty for the full description. |
Attribute: Blank::classMethod: Validation::blank() |
| 232 | Name: isUsage: see equals |
Alias, refer to equals for the full description. |
Attribute: Is::classMethod: Validation::is(mixed $value) |
| 233 | Name: sameUsage: see equals |
Alias, refer to equals for the full description. |
Attribute: Same::classMethod: Validation::same(mixed $value) |
| 234 | Name: patternUsage: see matches |
Alias, refer to matches for the full description. |
Attribute: Pattern::classMethod: Validation::pattern(string $pattern) |
| 235 | Name: choiceUsage: see in |
Alias, refer to in for the full description. |
Attribute: Choice::classMethod: Validation::choice(string|int|float|bool|null ...$values) |
| 236 | Name: sizeUsage: see count |
Alias, refer to count for the full description. |
Attribute: Size::classMethod: Validation::size(int $size) |
| 237 | Name: lengthUsage: see count |
Alias, refer to count for the full description. |
Attribute: Length::classMethod: Validation::length(int $count) |
| 238 | Name: rangeUsage: see between |
Alias, refer to between for the full description. |
Attribute: Range::classMethod: Validation::range(int|float $min, int|float $max) |
| 239 | Name: minmaxUsage: see between |
Alias, refer to between for the full description. |
Attribute: Minmax::classMethod: Validation::minmax(int|float $min, int|float $max) |
| 240 | Name: filledUsage: see required |
Alias, refer to required for the full description. |
Attribute: Filled::classMethod: Validation::filled() |
| 241 | Name: presentUsage: see required |
Alias, refer to required for the full description. |
Attribute: Present::classMethod: Validation::present() |
| 242 | Name: optionalUsage: see allowed |
Alias, refer to allowed for the full description. |
Attribute: Optional::classMethod: Validation::optional() |
| 243 | Name: dateUsage: see datetime |
Alias, refer to datetime for the full description. |
Attribute: Date::classMethod: Validation::date() |
| 244 | Name: date.equalsUsage: see datetime.eq |
Alias, refer to datetime.eq for the full description. |
Attribute: DateEquals::classMethod: Validation::dateEquals(string $datetime) |
| 245 | Name: date.beforeUsage: see datetime.lt |
Alias, refer to datetime.lt for the full description. |
Attribute: DateBefore::classMethod: Validation::dateBefore(string $datetime) |
| 246 | Name: date.beforeOrEqualsUsage: see datetime.lte |
Alias, refer to datetime.lte for the full description. |
Attribute: DateBeforeOrEquals::classMethod: Validation::dateBeforeOrEquals(string $datetime) |
| 247 | Name: date.afterUsage: see datetime.gt |
Alias, refer to datetime.gt for the full description. |
Attribute: DateAfter::classMethod: Validation::dateAfter(string $datetime) |
| 248 | Name: date.afterOrEqualsUsage: see datetime.gte |
Alias, refer to datetime.gte for the full description. |
Attribute: DateAfterOrEquals::classMethod: Validation::dateAfterOrEquals(string $datetime) |
| 249 | Name: date.formatUsage: see datetime.format |
Alias, refer to datetime.format for the full description. |
Attribute: DateFormat::classMethod: Validation::dateFormat(string $format) |
| 250 | Name: cakedayUsage: see datetime.birthday |
Alias, refer to datetime.birthday for the full description. |
Attribute: Cakeday::classMethod: Validation::cakeday() |
Macros
| Macro | Validation Expression |
|---|---|
[nullable] |
null^~empty |
[alnumDash] |
matches:"/[a-zA-Z0-9-_]+/" |
[twitterHandle] |
matches:'\"/^[a-zA-Z_]{1}[a-zA-Z0-9_]{0,14}$/\"' |
[gmail] |
email&string.contains:"@gmail." |
[eduMail] |
email&string.endsWith:".edu" |
Benchmarks
By now it may seem like Mighty is doing too much and performance concerns are starting to arise. Well, there is no need to worry about that. Mighty is really fast and is optimized to provide the best performance. Here are some benchmarks of the performance of the validator:
Not So Scientific Benchmark
The performance of Mighty Validator and Laravel Validator in a laravel application. The test was carried out using an array of 50000 elements, half of them are integers and the other half are numeric strings. Each validator was tested 10 times (consecutively) and the average result of these 10 was collected:
$data = array_merge(range(1, 25000), array_map('strval', range('25001', '50000'))); // Mighty Validator with XDebug disabled [ // required&integer 'preparationTime' => '1.32ms', // the time required to build the array 'validationTime' => '1107.29ms', // the time required to validate the array 'totalTime' => '1108.61ms', // the time required for the whole process ] // Mighty Validator with XDebug enabled [ // required&integer 'preparationTime' => '9.09ms', 'validationTime' => '6085.04ms', 'totalTime' => '6094.13ms', ] // Laravel Validator with XDebug disabled [ // required|integer 'preparationTime' => '1.33ms', 'validationTime' => '13882.72ms', 'totalTime' => '13884.05ms', ] // Laravel Validator with XDebug enabled [ // required|integer 'preparationTime' => '9.33ms', 'validationTime' => '24010.60ms', 'totalTime' => '24019.93ms', ]
So Mighty is about 12.5X times faster than Laravel Validator with XDebug disabled and about 4X times faster with XDebug enabled.
Scientific Benchmark
The benchmark is done using PHPBench. Here is a quick overview:
PHPBench (1.2.6) running benchmarks...
with configuration file: mighty/phpbench.json.dist
with PHP version 8.1.9, xdebug ❌, opcache ❌
\MAKS\Mighty\Benchmarks\ConstraintBench
benchAValidValidatableObject............I4 ✔ Mo305.595074ops/s (±0.75%)
benchAnInvalidValidatableObject.........I4 ✔ Mo326.708522ops/s (±1.02%)
\MAKS\Mighty\Benchmarks\ValidatorBench
benchSingleValidationString.............I4 ✔ Mo0.02212ms (±1.59%)
benchSingleValidationObject.............I4 ✔ Mo0.126929ms (±1.63%)
benchBulkValidationObject...............I4 ✔ Mo9.345847ms (±0.62%)
benchBulkValidationString...............I4 ✔ Mo6.734188ms (±0.40%)
Subjects: 6, Assertions: 6, Failures: 0, Errors: 0
Fact: The most recent benchmark result can also be found in the CI pipeline, which will be updated with each Push/PR to the upsteam.
Notes
- Mighty generates really friendly error messages by default (currently only in English). These messages can be easily overwritten on Validator/Constraint bases. You may want to have these messages in different languages, for that, the
MAKS\Mighty\Rule::setMessageTranslator()method can be used. This method is a convenient way to set a global message translator, it takes a closure that gets the raw message (with placeholders) as an argument and must return the translated version of that message. - Refer to the Mighty Validation Expression Language Specification to learn more about the theory behind Mighty and to get a grasp of how the language works.
- Refer to Mighty API Documentation to learn more about the PHP API. The API is well-documented and there shouldn't be anything that is not covered there.
- Mighty is currently a pure validation library, it doesn't do any kind of transformation on the data. The engine and the current design is flexible enough and can be used to easily implement a Sanitizer on top of it, there is no plan to make this at the moment but it may be a future milestone.
License
Mighty is an open-source project licensed under the MIT license.
Copyright (c) 2022 Marwan Al-Soltany. All rights reserved.
