From 061a3c9c0956e53ba71d9395431e154606e4a738 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 2 Dec 2024 22:11:57 +0100 Subject: [PATCH] Rename method "validate()" to "isValid()" The method has been renamed some time ago, but I haven't updated the documentation to cause less confusion. Now that I want to start updating the documentation, I switched the default branch on GitHub to the latest stable version, so I assume there will be less confusion in the documentation, and I can start updating the docs for the next version. --- README.md | 2 +- docs/02-feature-guide.md | 22 ++++++++++----------- docs/05-concrete-api.md | 6 +++--- docs/07-comparable-values.md | 10 +++++----- docs/index.md | 2 +- docs/rules/AllOf.md | 2 +- docs/rules/Alnum.md | 12 +++++------ docs/rules/Alpha.md | 12 +++++------ docs/rules/AlwaysInvalid.md | 2 +- docs/rules/AlwaysValid.md | 2 +- docs/rules/AnyOf.md | 2 +- docs/rules/ArrayType.md | 6 +++--- docs/rules/ArrayVal.md | 6 +++--- docs/rules/Base.md | 10 +++++----- docs/rules/Base64.md | 4 ++-- docs/rules/Between.md | 6 +++--- docs/rules/BetweenExclusive.md | 10 +++++----- docs/rules/BoolType.md | 4 ++-- docs/rules/BoolVal.md | 12 +++++------ docs/rules/Bsn.md | 2 +- docs/rules/Call.md | 2 +- docs/rules/CallableType.md | 6 +++--- docs/rules/Callback.md | 2 +- docs/rules/Charset.md | 6 +++--- docs/rules/Cnh.md | 2 +- docs/rules/Consecutive.md | 2 +- docs/rules/Consonant.md | 2 +- docs/rules/Contains.md | 4 ++-- docs/rules/ContainsAny.md | 4 ++-- docs/rules/Control.md | 2 +- docs/rules/Countable.md | 6 +++--- docs/rules/CountryCode.md | 8 ++++---- docs/rules/Cpf.md | 6 +++--- docs/rules/CreditCard.md | 24 +++++++++++----------- docs/rules/CurrencyCode.md | 2 +- docs/rules/Date.md | 12 +++++------ docs/rules/DateTime.md | 14 ++++++------- docs/rules/DateTimeDiff.md | 10 +++++----- docs/rules/Decimal.md | 8 ++++---- docs/rules/Digit.md | 8 ++++---- docs/rules/Directory.md | 8 ++++---- docs/rules/Domain.md | 4 ++-- docs/rules/Each.md | 4 ++-- docs/rules/Email.md | 2 +- docs/rules/EndsWith.md | 4 ++-- docs/rules/Equals.md | 2 +- docs/rules/Equivalent.md | 6 +++--- docs/rules/Even.md | 2 +- docs/rules/Executable.md | 2 +- docs/rules/Exists.md | 6 +++--- docs/rules/Extension.md | 2 +- docs/rules/Factor.md | 6 +++--- docs/rules/FalseVal.md | 16 +++++++-------- docs/rules/Fibonacci.md | 6 +++--- docs/rules/File.md | 6 +++--- docs/rules/FilterVar.md | 14 ++++++------- docs/rules/Finite.md | 4 ++-- docs/rules/FloatType.md | 6 +++--- docs/rules/FloatVal.md | 4 ++-- docs/rules/Graph.md | 2 +- docs/rules/GreaterThan.md | 4 ++-- docs/rules/GreaterThanOrEqual.md | 6 +++--- docs/rules/Hetu.md | 8 ++++---- docs/rules/HexRgbColor.md | 8 ++++---- docs/rules/Iban.md | 10 +++++----- docs/rules/Identical.md | 4 ++-- docs/rules/Image.md | 6 +++--- docs/rules/Imei.md | 4 ++-- docs/rules/In.md | 4 ++-- docs/rules/Infinite.md | 2 +- docs/rules/Instance.md | 4 ++-- docs/rules/IntType.md | 4 ++-- docs/rules/IntVal.md | 14 ++++++------- docs/rules/Ip.md | 14 ++++++------- docs/rules/Isbn.md | 8 ++++---- docs/rules/IterableType.md | 8 ++++---- docs/rules/IterableVal.md | 8 ++++---- docs/rules/Json.md | 2 +- docs/rules/Key.md | 8 ++++---- docs/rules/KeyExists.md | 12 +++++------ docs/rules/KeyOptional.md | 10 +++++----- docs/rules/KeySet.md | 14 ++++++------- docs/rules/LanguageCode.md | 10 +++++----- docs/rules/Lazy.md | 4 ++-- docs/rules/LeapDate.md | 2 +- docs/rules/LeapYear.md | 2 +- docs/rules/Length.md | 10 +++++----- docs/rules/LessThan.md | 4 ++-- docs/rules/LessThanOrEqual.md | 6 +++--- docs/rules/Lowercase.md | 2 +- docs/rules/Luhn.md | 4 ++-- docs/rules/MacAddress.md | 4 ++-- docs/rules/Max.md | 8 ++++---- docs/rules/Mimetype.md | 4 ++-- docs/rules/Min.md | 8 ++++---- docs/rules/Multiple.md | 2 +- docs/rules/Negative.md | 2 +- docs/rules/NfeAccessKey.md | 2 +- docs/rules/Nif.md | 4 ++-- docs/rules/Nip.md | 10 +++++----- docs/rules/No.md | 18 ++++++++--------- docs/rules/NoWhitespace.md | 4 ++-- docs/rules/NoneOf.md | 2 +- docs/rules/Not.md | 4 ++-- docs/rules/NotBlank.md | 32 +++++++++++++++--------------- docs/rules/NotEmoji.md | 12 +++++------ docs/rules/NotEmpty.md | 12 +++++------ docs/rules/NotUndef.md | 32 +++++++++++++++--------------- docs/rules/NullType.md | 2 +- docs/rules/Nullable.md | 6 +++--- docs/rules/Number.md | 4 ++-- docs/rules/NumericVal.md | 4 ++-- docs/rules/ObjectType.md | 2 +- docs/rules/Odd.md | 4 ++-- docs/rules/OneOf.md | 8 ++++---- docs/rules/PerfectSquare.md | 4 ++-- docs/rules/Pesel.md | 8 ++++---- docs/rules/Phone.md | 6 +++--- docs/rules/PhpLabel.md | 6 +++--- docs/rules/Pis.md | 10 +++++----- docs/rules/PolishIdCard.md | 8 ++++---- docs/rules/PortugueseNif.md | 4 ++-- docs/rules/Positive.md | 6 +++--- docs/rules/PostalCode.md | 14 ++++++------- docs/rules/PrimeNumber.md | 2 +- docs/rules/Printable.md | 2 +- docs/rules/Property.md | 6 +++--- docs/rules/PropertyExists.md | 6 +++--- docs/rules/PropertyOptional.md | 14 ++++++------- docs/rules/PublicDomainSuffix.md | 10 +++++----- docs/rules/Punct.md | 2 +- docs/rules/Readable.md | 2 +- docs/rules/Regex.md | 2 +- docs/rules/ResourceType.md | 2 +- docs/rules/Roman.md | 2 +- docs/rules/ScalarVal.md | 4 ++-- docs/rules/Size.md | 8 ++++---- docs/rules/Slug.md | 6 +++--- docs/rules/Sorted.md | 16 +++++++-------- docs/rules/Space.md | 2 +- docs/rules/StartsWith.md | 4 ++-- docs/rules/StringType.md | 2 +- docs/rules/StringVal.md | 14 ++++++------- docs/rules/SubdivisionCode.md | 4 ++-- docs/rules/Subset.md | 4 ++-- docs/rules/SymbolicLink.md | 6 +++--- docs/rules/Time.md | 18 ++++++++--------- docs/rules/Tld.md | 8 ++++---- docs/rules/TrueVal.md | 16 +++++++-------- docs/rules/Type.md | 6 +++--- docs/rules/UndefOr.md | 12 +++++------ docs/rules/Unique.md | 8 ++++---- docs/rules/Uploaded.md | 2 +- docs/rules/Uppercase.md | 8 ++++---- docs/rules/Url.md | 10 +++++----- docs/rules/Uuid.md | 8 ++++---- docs/rules/Version.md | 2 +- docs/rules/VideoUrl.md | 34 ++++++++++++++++---------------- docs/rules/Vowel.md | 2 +- docs/rules/When.md | 8 ++++---- docs/rules/Writable.md | 2 +- docs/rules/Xdigit.md | 4 ++-- docs/rules/Yes.md | 16 +++++++-------- 163 files changed, 558 insertions(+), 558 deletions(-) diff --git a/README.md b/README.md index fb1709a60..619a3e436 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The most awesome validation engine ever created for PHP. -- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->validate($input)`. +- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->isValid($input)`. - [Granularity control](docs/02-feature-guide.md#validation-methods) for advanced reporting. - [More than 150](docs/08-list-of-rules-by-category.md) (fully tested) validation rules. - [A concrete API](docs/05-concrete-api.md) for non fluent usage. diff --git a/docs/02-feature-guide.md b/docs/02-feature-guide.md index 632213346..fa8fe6ac2 100644 --- a/docs/02-feature-guide.md +++ b/docs/02-feature-guide.md @@ -15,7 +15,7 @@ The Hello World validator is something like this: ```php $number = 123; -v::numericVal()->validate($number); // true +v::numericVal()->isValid($number); // true ``` ## Chained validation @@ -25,7 +25,7 @@ containing numbers and letters, no whitespace and length between 1 and 15. ```php $usernameValidator = v::alnum()->noWhitespace()->length(1, 15); -$usernameValidator->validate('alganet'); // true +$usernameValidator->isValid('alganet'); // true ``` ## Validating object properties @@ -44,7 +44,7 @@ Is possible to validate its properties in a single chain: $userValidator = v::property('name', v::stringType()->length(1, 32)) ->property('birthdate', v::dateTimeDiff(v::greaterThanOrEqual(18), 'years')); -$userValidator->validate($user); // true +$userValidator->isValid($user); // true ``` Validating array keys is also possible using `v::key()` @@ -93,11 +93,11 @@ For that reason all rules are mandatory now but if you want to treat a value as optional you can use `v::optional()` rule: ```php -v::alpha()->validate(''); // false input required -v::alpha()->validate(null); // false input required +v::alpha()->isValid(''); // false input required +v::alpha()->isValid(null); // false input required -v::optional(v::alpha())->validate(''); // true -v::optional(v::alpha())->validate(null); // true +v::optional(v::alpha())->isValid(''); // true +v::optional(v::alpha())->isValid(null); // true ``` By _optional_ we consider `null` or an empty string (`''`). @@ -109,7 +109,7 @@ See more on [Optional](rules/UndefOr.md). You can use the `v::not()` to negate any rule: ```php -v::not(v::intVal())->validate(10); // false, input must not be integer +v::not(v::intVal())->isValid(10); // false, input must not be integer ``` ## Validator reuse @@ -117,9 +117,9 @@ v::not(v::intVal())->validate(10); // false, input must not be integer Once created, you can reuse your validator anywhere. Remember `$usernameValidator`? ```php -$usernameValidator->validate('respect'); //true -$usernameValidator->validate('alexandre gaigalas'); // false -$usernameValidator->validate('#$%'); //false +$usernameValidator->isValid('respect'); //true +$usernameValidator->isValid('alexandre gaigalas'); // false +$usernameValidator->isValid('#$%'); //false ``` ## Exception types diff --git a/docs/05-concrete-api.md b/docs/05-concrete-api.md index b372a9952..d5ce6129a 100644 --- a/docs/05-concrete-api.md +++ b/docs/05-concrete-api.md @@ -8,7 +8,7 @@ or magic methods. We'll use a traditional dependency injection approach. use Respect\Validation\Validator as v; $usernameValidator = v::alnum()->noWhitespace()->length(1, 15); -$usernameValidator->validate('alganet'); // true +$usernameValidator->isValid('alganet'); // true ``` If you `var_dump($usernameValidator)`, you'll see a composite of objects with @@ -24,7 +24,7 @@ $usernameValidator = new Rules\AllOf( new Rules\NoWhitespace(), new Rules\Length(1, 15) ); -$usernameValidator->validate('alganet'); // true +$usernameValidator->isValid('alganet'); // true ``` This is still a very lean API. You can use it in any dependency injection @@ -39,7 +39,7 @@ $usernameValidator = new Rules\AllOf( new Rules\Length(1, 15) ); $userValidator = new Rules\Key('name', $usernameValidator); -$userValidator->validate(['name' => 'alganet']); // true +$userValidator->isValid(['name' => 'alganet']); // true ``` ## How It Works? diff --git a/docs/07-comparable-values.md b/docs/07-comparable-values.md index 5fb6d4c93..cb304d6be 100644 --- a/docs/07-comparable-values.md +++ b/docs/07-comparable-values.md @@ -16,15 +16,15 @@ that can be parsed by PHP Below you can see some examples: ```php -v::greaterThanOrEqual(100)->validate($collection); // true if it has at least 100 items +v::greaterThanOrEqual(100)->isValid($collection); // true if it has at least 100 items v::dateTime() ->between(new DateTime('yesterday'), new DateTime('tomorrow')) - ->validate(new DateTime('now')); // true + ->isValid(new DateTime('now')); // true -v::numericVal()->lessThanOrEqual(10)->validate(5); // true +v::numericVal()->lessThanOrEqual(10)->isValid(5); // true -v::stringVal()->between('a', 'f')->validate('d'); // true +v::stringVal()->between('a', 'f')->isValid('d'); // true -v::dateTime()->between('yesterday', 'tomorrow')->validate('now'); // true +v::dateTime()->between('yesterday', 'tomorrow')->isValid('now'); // true ``` diff --git a/docs/index.md b/docs/index.md index 2d172b960..0a94f5bdb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ The most awesome validation engine ever created for PHP. -- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->validate($input)`. +- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->isValid($input)`. - [Granularity control](02-feature-guide.md#validation-methods) for advanced reporting. - [More than 150](08-list-of-rules-by-category.md) (fully tested) validation rules. - [A concrete API](05-concrete-api.md) for non fluent usage. diff --git a/docs/rules/AllOf.md b/docs/rules/AllOf.md index a89782916..8d7de2a7b 100644 --- a/docs/rules/AllOf.md +++ b/docs/rules/AllOf.md @@ -5,7 +5,7 @@ Will validate if all inner validators validates. ```php -v::allOf(v::intVal(), v::positive())->validate(15); // true +v::allOf(v::intVal(), v::positive())->isValid(15); // true ``` ## Categorization diff --git a/docs/rules/Alnum.md b/docs/rules/Alnum.md index 952ed695c..2ae54acf6 100644 --- a/docs/rules/Alnum.md +++ b/docs/rules/Alnum.md @@ -9,18 +9,18 @@ Alphanumeric is a combination of alphabetic (a-z and A-Z) and numeric (0-9) characters. ```php -v::alnum()->validate('foo 123'); // false -v::alnum(' ')->validate('foo 123'); // true -v::alnum()->validate('100%'); // false -v::alnum('%')->validate('100%'); // true -v::alnum('%', ',')->validate('10,5%'); // true +v::alnum()->isValid('foo 123'); // false +v::alnum(' ')->isValid('foo 123'); // true +v::alnum()->isValid('100%'); // false +v::alnum('%')->isValid('100%'); // true +v::alnum('%', ',')->isValid('10,5%'); // true ``` You can restrict case using the [Lowercase](Lowercase.md) and [Uppercase](Uppercase.md) rules. ```php -v::alnum()->uppercase()->validate('example'); // false +v::alnum()->uppercase()->isValid('example'); // false ``` Message template for this validator includes `{{additionalChars}}` as the string diff --git a/docs/rules/Alpha.md b/docs/rules/Alpha.md index 510b084b6..795279041 100644 --- a/docs/rules/Alpha.md +++ b/docs/rules/Alpha.md @@ -7,18 +7,18 @@ Validates whether the input contains only alphabetic characters. This is similar to [Alnum](Alnum.md), but it does not allow numbers. ```php -v::alpha()->validate('some name'); // false -v::alpha(' ')->validate('some name'); // true -v::alpha()->validate('Cedric-Fabian'); // false -v::alpha('-')->validate('Cedric-Fabian'); // true -v::alpha('-', '\'')->validate('\'s-Gravenhage'); // true +v::alpha()->isValid('some name'); // false +v::alpha(' ')->isValid('some name'); // true +v::alpha()->isValid('Cedric-Fabian'); // false +v::alpha('-')->isValid('Cedric-Fabian'); // true +v::alpha('-', '\'')->isValid('\'s-Gravenhage'); // true ``` You can restrict case using the [Lowercase](Lowercase.md) and [Uppercase](Uppercase.md) rules. ```php -v::alpha()->uppercase()->validate('example'); // false +v::alpha()->uppercase()->isValid('example'); // false ``` ## Categorization diff --git a/docs/rules/AlwaysInvalid.md b/docs/rules/AlwaysInvalid.md index f298d38ee..52e2ef2f4 100644 --- a/docs/rules/AlwaysInvalid.md +++ b/docs/rules/AlwaysInvalid.md @@ -5,7 +5,7 @@ Validates any input as invalid. ```php -v::alwaysInvalid()->validate('whatever'); // false +v::alwaysInvalid()->isValid('whatever'); // false ``` ## Categorization diff --git a/docs/rules/AlwaysValid.md b/docs/rules/AlwaysValid.md index c83d9f458..646afc51a 100644 --- a/docs/rules/AlwaysValid.md +++ b/docs/rules/AlwaysValid.md @@ -5,7 +5,7 @@ Validates any input as valid. ```php -v::alwaysValid()->validate('whatever'); // true +v::alwaysValid()->isValid('whatever'); // true ``` ## Categorization diff --git a/docs/rules/AnyOf.md b/docs/rules/AnyOf.md index 0a1ae0c24..213b49b1f 100644 --- a/docs/rules/AnyOf.md +++ b/docs/rules/AnyOf.md @@ -5,7 +5,7 @@ This is a group validator that acts as an OR operator. ```php -v::anyOf(v::intVal(), v::floatVal())->validate(15.5); // true +v::anyOf(v::intVal(), v::floatVal())->isValid(15.5); // true ``` In the sample above, `IntVal()` doesn't validates, but `FloatVal()` validates, diff --git a/docs/rules/ArrayType.md b/docs/rules/ArrayType.md index 374061eb6..7e0c4b152 100644 --- a/docs/rules/ArrayType.md +++ b/docs/rules/ArrayType.md @@ -5,9 +5,9 @@ Validates whether the type of an input is array. ```php -v::arrayType()->validate([]); // true -v::arrayType()->validate([1, 2, 3]); // true -v::arrayType()->validate(new ArrayObject()); // false +v::arrayType()->isValid([]); // true +v::arrayType()->isValid([1, 2, 3]); // true +v::arrayType()->isValid(new ArrayObject()); // false ``` ## Categorization diff --git a/docs/rules/ArrayVal.md b/docs/rules/ArrayVal.md index ca660acac..8e549a549 100644 --- a/docs/rules/ArrayVal.md +++ b/docs/rules/ArrayVal.md @@ -6,9 +6,9 @@ Validates if the input is an array or if the input can be used as an array (instance of `ArrayAccess` or `SimpleXMLElement`). ```php -v::arrayVal()->validate([]); // true -v::arrayVal()->validate(new ArrayObject); // true -v::arrayVal()->validate(new SimpleXMLElement('')); // true +v::arrayVal()->isValid([]); // true +v::arrayVal()->isValid(new ArrayObject); // true +v::arrayVal()->isValid(new SimpleXMLElement('')); // true ``` ## Categorization diff --git a/docs/rules/Base.md b/docs/rules/Base.md index 402ecf6af..c8065c68e 100644 --- a/docs/rules/Base.md +++ b/docs/rules/Base.md @@ -5,11 +5,11 @@ Validate numbers in any base, even with non regular bases. ```php -v::base(2)->validate('011010001'); // true -v::base(3)->validate('0120122001'); // true -v::base(8)->validate('01234567520'); // true -v::base(16)->validate('012a34f5675c20d'); // true -v::base(2)->validate('0120122001'); // false +v::base(2)->isValid('011010001'); // true +v::base(3)->isValid('0120122001'); // true +v::base(8)->isValid('01234567520'); // true +v::base(16)->isValid('012a34f5675c20d'); // true +v::base(2)->isValid('0120122001'); // false ``` ## Categorization diff --git a/docs/rules/Base64.md b/docs/rules/Base64.md index 7e4e5b34a..3b742a5d5 100644 --- a/docs/rules/Base64.md +++ b/docs/rules/Base64.md @@ -5,8 +5,8 @@ Validate if a string is Base64-encoded. ```php -v::base64()->validate('cmVzcGVjdCE='); // true -v::base64()->validate('respect!'); // false +v::base64()->isValid('cmVzcGVjdCE='); // true +v::base64()->isValid('respect!'); // false ``` ## Categorization diff --git a/docs/rules/Between.md b/docs/rules/Between.md index bb8a519da..feca23e53 100644 --- a/docs/rules/Between.md +++ b/docs/rules/Between.md @@ -5,9 +5,9 @@ Validates whether the input is between two other values. ```php -v::intVal()->between(10, 20)->validate(10); // true -v::intVal()->between(10, 20)->validate(15); // true -v::intVal()->between(10, 20)->validate(20); // true +v::intVal()->between(10, 20)->isValid(10); // true +v::intVal()->between(10, 20)->isValid(15); // true +v::intVal()->between(10, 20)->isValid(20); // true ``` Validation makes comparison easier, check out our supported diff --git a/docs/rules/BetweenExclusive.md b/docs/rules/BetweenExclusive.md index b2c966909..6bdd850d9 100644 --- a/docs/rules/BetweenExclusive.md +++ b/docs/rules/BetweenExclusive.md @@ -5,12 +5,12 @@ Validates whether the input is between two other values, exclusively. ```php -v::betweenExclusive(10, 20)->validate(10); // true -v::betweenExclusive('a', 'e')->validate('c'); // true -v::betweenExclusive(new DateTime('yesterday'), new DateTime('tomorrow'))->validate(new DateTime('today')); // true +v::betweenExclusive(10, 20)->isValid(10); // true +v::betweenExclusive('a', 'e')->isValid('c'); // true +v::betweenExclusive(new DateTime('yesterday'), new DateTime('tomorrow'))->isValid(new DateTime('today')); // true -v::betweenExclusive(0, 100)->validate(100); // false -v::betweenExclusive('a', 'z')->validate('a'); // false +v::betweenExclusive(0, 100)->isValid(100); // false +v::betweenExclusive('a', 'z')->isValid('a'); // false ``` Validation makes comparison easier, check out our supported [comparable values](../07-comparable-values.md). diff --git a/docs/rules/BoolType.md b/docs/rules/BoolType.md index d5d90990e..70ccf5007 100644 --- a/docs/rules/BoolType.md +++ b/docs/rules/BoolType.md @@ -5,8 +5,8 @@ Validates whether the type of the input is [boolean](http://php.net/types.boolean). ```php -v::boolType()->validate(true); // true -v::boolType()->validate(false); // true +v::boolType()->isValid(true); // true +v::boolType()->isValid(false); // true ``` ## Categorization diff --git a/docs/rules/BoolVal.md b/docs/rules/BoolVal.md index 536ac1e31..792ee42d1 100644 --- a/docs/rules/BoolVal.md +++ b/docs/rules/BoolVal.md @@ -5,12 +5,12 @@ Validates if the input results in a boolean value: ```php -v::boolVal()->validate('on'); // true -v::boolVal()->validate('off'); // true -v::boolVal()->validate('yes'); // true -v::boolVal()->validate('no'); // true -v::boolVal()->validate(1); // true -v::boolVal()->validate(0); // true +v::boolVal()->isValid('on'); // true +v::boolVal()->isValid('off'); // true +v::boolVal()->isValid('yes'); // true +v::boolVal()->isValid('no'); // true +v::boolVal()->isValid(1); // true +v::boolVal()->isValid(0); // true ``` ## Categorization diff --git a/docs/rules/Bsn.md b/docs/rules/Bsn.md index 21822fbf0..5441a16a7 100644 --- a/docs/rules/Bsn.md +++ b/docs/rules/Bsn.md @@ -5,7 +5,7 @@ Validates a Dutch citizen service number ([BSN](https://nl.wikipedia.org/wiki/Burgerservicenummer)). ```php -v::bsn()->validate('612890053'); // true +v::bsn()->isValid('612890053'); // true ``` ## Categorization diff --git a/docs/rules/Call.md b/docs/rules/Call.md index e70b669ad..b8d70a10f 100644 --- a/docs/rules/Call.md +++ b/docs/rules/Call.md @@ -38,7 +38,7 @@ v::call( ->key('host', v::domain()) ->key('path', v::stringType()) ->key('query', v::notEmpty()) -)->validate($url); +)->isValid($url); ``` ## Categorization diff --git a/docs/rules/CallableType.md b/docs/rules/CallableType.md index 5c62c1679..06af93d5b 100644 --- a/docs/rules/CallableType.md +++ b/docs/rules/CallableType.md @@ -5,9 +5,9 @@ Validates whether the pseudo-type of the input is [callable](http://php.net/types.callable). ```php -v::callableType()->validate(function () {}); // true -v::callableType()->validate('trim'); // true -v::callableType()->validate([new DateTime(), 'format']); // true +v::callableType()->isValid(function () {}); // true +v::callableType()->isValid('trim'); // true +v::callableType()->isValid([new DateTime(), 'format']); // true ``` ## Categorization diff --git a/docs/rules/Callback.md b/docs/rules/Callback.md index 620dd0877..d560edae1 100644 --- a/docs/rules/Callback.md +++ b/docs/rules/Callback.md @@ -9,7 +9,7 @@ v::callback( function (int $input): bool { return $input + ($input / 2) == 15; } -)->validate(10); // true +)->isValid(10); // true ``` ## Categorization diff --git a/docs/rules/Charset.md b/docs/rules/Charset.md index 2c89e9a18..89eb2e95d 100644 --- a/docs/rules/Charset.md +++ b/docs/rules/Charset.md @@ -5,9 +5,9 @@ Validates if a string is in a specific charset. ```php -v::charset('ASCII')->validate('açúcar'); // false -v::charset('ASCII')->validate('sugar'); //true -v::charset('ISO-8859-1', 'EUC-JP')->validate('日本国'); // true +v::charset('ASCII')->isValid('açúcar'); // false +v::charset('ASCII')->isValid('sugar'); //true +v::charset('ISO-8859-1', 'EUC-JP')->isValid('日本国'); // true ``` The array format is a logic OR, not AND. diff --git a/docs/rules/Cnh.md b/docs/rules/Cnh.md index 2bd1ebc67..00fd980a6 100644 --- a/docs/rules/Cnh.md +++ b/docs/rules/Cnh.md @@ -5,7 +5,7 @@ Validates a Brazilian driver's license. ```php -v::cnh()->validate('02650306461'); // true +v::cnh()->isValid('02650306461'); // true ``` ## Categorization diff --git a/docs/rules/Consecutive.md b/docs/rules/Consecutive.md index e984340d3..36fc085d5 100644 --- a/docs/rules/Consecutive.md +++ b/docs/rules/Consecutive.md @@ -13,7 +13,7 @@ country code and a subdivision code. v::consecutive( v::key('countryCode', v::countryCode()), v::lazy(static fn($input) => v::key('subdivisionCode', v::subdivisionCode($input['countryCode']))), -)->validate($_POST); +)->isValid($_POST); ``` You need a valid country code to create a [SubdivisionCode](SubdivisionCode.md), so it makes sense only to validate the diff --git a/docs/rules/Consonant.md b/docs/rules/Consonant.md index 70c230eca..6a3f17bac 100644 --- a/docs/rules/Consonant.md +++ b/docs/rules/Consonant.md @@ -6,7 +6,7 @@ Validates if the input contains only consonants. ```php -v::consonant()->validate('xkcd'); // true +v::consonant()->isValid('xkcd'); // true ``` ## Categorization diff --git a/docs/rules/Contains.md b/docs/rules/Contains.md index d975937ce..2707b95dd 100644 --- a/docs/rules/Contains.md +++ b/docs/rules/Contains.md @@ -8,13 +8,13 @@ Validates if the input contains some value. For strings: ```php -v::contains('ipsum')->validate('lorem ipsum'); // true +v::contains('ipsum')->isValid('lorem ipsum'); // true ``` For arrays: ```php -v::contains('ipsum')->validate(['ipsum', 'lorem']); // true +v::contains('ipsum')->isValid(['ipsum', 'lorem']); // true ``` A second parameter may be passed for identical comparison instead diff --git a/docs/rules/ContainsAny.md b/docs/rules/ContainsAny.md index e1ab89a8a..492b0ad27 100644 --- a/docs/rules/ContainsAny.md +++ b/docs/rules/ContainsAny.md @@ -8,13 +8,13 @@ Validates if the input contains at least one of defined values For strings (comparing is case insensitive): ```php -v::containsAny(['lorem', 'dolor'])->validate('lorem ipsum'); // true +v::containsAny(['lorem', 'dolor'])->isValid('lorem ipsum'); // true ``` For arrays (comparing is case sensitive to respect "contains" behavior): ```php -v::containsAny(['lorem', 'dolor'])->validate(['ipsum', 'lorem']); // true +v::containsAny(['lorem', 'dolor'])->isValid(['ipsum', 'lorem']); // true ``` A second parameter may be passed for identical comparison instead diff --git a/docs/rules/Control.md b/docs/rules/Control.md index 126fb8384..c4c75a117 100644 --- a/docs/rules/Control.md +++ b/docs/rules/Control.md @@ -7,7 +7,7 @@ Validates if all of the characters in the provided string, are control characters. ```php -v::control()->validate("\n\r\t"); // true +v::control()->isValid("\n\r\t"); // true ``` ## Categorization diff --git a/docs/rules/Countable.md b/docs/rules/Countable.md index e85eb9f5a..7056948cd 100644 --- a/docs/rules/Countable.md +++ b/docs/rules/Countable.md @@ -6,9 +6,9 @@ Validates if the input is countable, in other words, if you're allowed to use [count()](http://php.net/count) function on it. ```php -v::countable()->validate([]); // true -v::countable()->validate(new ArrayObject()); // true -v::countable()->validate('string'); // false +v::countable()->isValid([]); // true +v::countable()->isValid(new ArrayObject()); // true +v::countable()->isValid('string'); // false ``` ## Categorization diff --git a/docs/rules/CountryCode.md b/docs/rules/CountryCode.md index 32c3a1fdb..9af9fae4e 100644 --- a/docs/rules/CountryCode.md +++ b/docs/rules/CountryCode.md @@ -8,11 +8,11 @@ Validates whether the input is a country code in [ISO 3166-1][] standard. **This rule requires [sokil/php-isocodes][] and [sokil/php-isocodes-db-only][] to be installed.** ```php -v::countryCode()->validate('BR'); // true +v::countryCode()->isValid('BR'); // true -v::countryCode('alpha-2')->validate('NL'); // true -v::countryCode('alpha-3')->validate('USA'); // true -v::countryCode('numeric')->validate('504'); // true +v::countryCode('alpha-2')->isValid('NL'); // true +v::countryCode('alpha-3')->isValid('USA'); // true +v::countryCode('numeric')->isValid('504'); // true ``` This rule supports the three sets of country codes: diff --git a/docs/rules/Cpf.md b/docs/rules/Cpf.md index d4f172d39..d35176b78 100644 --- a/docs/rules/Cpf.md +++ b/docs/rules/Cpf.md @@ -5,20 +5,20 @@ Validates a Brazillian CPF number. ```php -v::cpf()->validate('11598647644'); // true +v::cpf()->isValid('11598647644'); // true ``` It ignores any non-digit char: ```php -v::cpf()->validate('693.319.118-40'); // true +v::cpf()->isValid('693.319.118-40'); // true ``` If you need to validate digits only, add `->digit()` to the chain: ```php -v::digit()->cpf()->validate('11598647644'); // true +v::digit()->cpf()->isValid('11598647644'); // true ``` ## Categorization diff --git a/docs/rules/CreditCard.md b/docs/rules/CreditCard.md index d7fde7f28..0fb2297ae 100644 --- a/docs/rules/CreditCard.md +++ b/docs/rules/CreditCard.md @@ -6,17 +6,17 @@ Validates a credit card number. ```php -v::creditCard()->validate('5376 7473 9720 8720'); // true -v::creditCard()->validate('5376-7473-9720-8720'); // true -v::creditCard()->validate('5376.7473.9720.8720'); // true - -v::creditCard('American_Express')->validate('340316193809364'); // true -v::creditCard('Diners_Club')->validate('30351042633884'); // true -v::creditCard('Discover')->validate('6011000990139424'); // true -v::creditCard('JCB')->validate('3566002020360505'); // true -v::creditCard('Mastercard')->validate('5376747397208720'); // true -v::creditCard('Visa')->validate('4024007153361885'); // true -v::creaditCard('RuPay')->validate('6062973831636410') // true +v::creditCard()->isValid('5376 7473 9720 8720'); // true +v::creditCard()->isValid('5376-7473-9720-8720'); // true +v::creditCard()->isValid('5376.7473.9720.8720'); // true + +v::creditCard('American_Express')->isValid('340316193809364'); // true +v::creditCard('Diners_Club')->isValid('30351042633884'); // true +v::creditCard('Discover')->isValid('6011000990139424'); // true +v::creditCard('JCB')->isValid('3566002020360505'); // true +v::creditCard('Mastercard')->isValid('5376747397208720'); // true +v::creditCard('Visa')->isValid('4024007153361885'); // true +v::creaditCard('RuPay')->isValid('6062973831636410') // true ``` The current supported brands are: @@ -33,7 +33,7 @@ It ignores any non-numeric characters, use [Digit](Digit.md), [NoWhitespace](NoWhitespace.md), or [Regex](Regex.md) when appropriate. ```php -v::digit()->creditCard()->validate('5376747397208720'); // true +v::digit()->creditCard()->isValid('5376747397208720'); // true ``` ## Categorization diff --git a/docs/rules/CurrencyCode.md b/docs/rules/CurrencyCode.md index 53fb2f292..96d059047 100644 --- a/docs/rules/CurrencyCode.md +++ b/docs/rules/CurrencyCode.md @@ -8,7 +8,7 @@ Validates an [ISO 4217][] currency code. **This rule requires [sokil/php-isocodes][] and [sokil/php-isocodes-db-only][] to be installed.** ```php -v::currencyCode()->validate('GBP'); // true +v::currencyCode()->isValid('GBP'); // true ``` This rule supports the two [ISO 4217][] sets: diff --git a/docs/rules/Date.md b/docs/rules/Date.md index 475b496fa..bd69a55a1 100644 --- a/docs/rules/Date.md +++ b/docs/rules/Date.md @@ -22,12 +22,12 @@ Format | Description When a `$format` is not given its default value is `Y-m-d`. ```php -v::date()->validate('2017-12-31'); // true -v::date()->validate('2020-02-29'); // true -v::date()->validate('2019-02-29'); // false -v::date('m/d/y')->validate('12/31/17'); // true -v::date('F jS, Y')->validate('May 1st, 2017'); // true -v::date('Ydm')->validate(20173112); // true +v::date()->isValid('2017-12-31'); // true +v::date()->isValid('2020-02-29'); // true +v::date()->isValid('2019-02-29'); // false +v::date('m/d/y')->isValid('12/31/17'); // true +v::date('F jS, Y')->isValid('May 1st, 2017'); // true +v::date('Ydm')->isValid(20173112); // true ``` ## Categorization diff --git a/docs/rules/DateTime.md b/docs/rules/DateTime.md index ef42b7229..53120af6d 100644 --- a/docs/rules/DateTime.md +++ b/docs/rules/DateTime.md @@ -10,26 +10,26 @@ The `$format` argument should be in accordance to [DateTime::format()][]. See mo When a `$format` is not given its default value is `Y-m-d H:i:s`. ```php -v::dateTime()->validate('2009-01-01'); // true +v::dateTime()->isValid('2009-01-01'); // true ``` Also accepts [strtotime()](http://php.net/strtotime) values: ```php -v::dateTime()->validate('now'); // true +v::dateTime()->isValid('now'); // true ``` And `DateTimeInterface` instances: ```php -v::dateTime()->validate(new DateTime()); // true -v::dateTime()->validate(new DateTimeImmutable()); // true +v::dateTime()->isValid(new DateTime()); // true +v::dateTime()->isValid(new DateTimeImmutable()); // true ``` You can pass a format when validating strings: ```php -v::dateTime('Y-m-d')->validate('01-01-2009'); // false +v::dateTime('Y-m-d')->isValid('01-01-2009'); // false ``` Format has no effect when validating DateTime instances. @@ -50,9 +50,9 @@ you desire, and you may want to use [Callback](Callback.md) to create a custom v $input = '2014-04-12T23:20:50.052Z'; v::callback(fn($input) => is_string($input) && DateTime::createFromFormat(DateTime::RFC3339_EXTENDED, $input)) - ->validate($input); // true + ->isValid($input); // true -v::dateTime(DateTime::RFC3339_EXTENDED)->validate($input); // false +v::dateTime(DateTime::RFC3339_EXTENDED)->isValid($input); // false ``` ## Categorization diff --git a/docs/rules/DateTimeDiff.md b/docs/rules/DateTimeDiff.md index d7025c8af..59aaf6703 100644 --- a/docs/rules/DateTimeDiff.md +++ b/docs/rules/DateTimeDiff.md @@ -9,13 +9,13 @@ The `$format` argument should follow PHP's [date()][] function. When the `$forma [Supported Date and Time Formats][] by PHP (see [strtotime()][]). ```php -v::dateTimeDiff('years', v::equals(7))->validate('7 years ago'); // true -v::dateTimeDiff('years', v::equals(7))->validate('7 years ago + 1 minute'); // false +v::dateTimeDiff('years', v::equals(7))->isValid('7 years ago'); // true +v::dateTimeDiff('years', v::equals(7))->isValid('7 years ago + 1 minute'); // false -v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->validate('09/12/1990'); // true -v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->validate('09/12/2023'); // false +v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->isValid('09/12/1990'); // true +v::dateTimeDiff('years', v::greaterThan(18), 'd/m/Y')->isValid('09/12/2023'); // false -v::dateTimeDiff('months', v::between(1, 18))->validate('5 months ago'); // true +v::dateTimeDiff('months', v::between(1, 18))->isValid('5 months ago'); // true ``` The supported types are: diff --git a/docs/rules/Decimal.md b/docs/rules/Decimal.md index 0ae459e0c..47c9ad984 100644 --- a/docs/rules/Decimal.md +++ b/docs/rules/Decimal.md @@ -5,9 +5,9 @@ Validates whether the input matches the expected number of decimals. ```php -v::decimals(2)->validate('27990.50'); // true -v::decimals(1)->validate('27990.50'); // false -v::decimal(1)->validate(1.5); // true +v::decimals(2)->isValid('27990.50'); // true +v::decimals(1)->isValid('27990.50'); // false +v::decimal(1)->isValid(1.5); // true ``` @@ -17,7 +17,7 @@ When validating float types, it is not possible to determine the amount of ending zeros and because of that, validations like the ones below will pass. ```php -v::decimal(1)->validate(1.50); // true +v::decimal(1)->isValid(1.50); // true ``` ## Categorization diff --git a/docs/rules/Digit.md b/docs/rules/Digit.md index 9432432fd..ee9314ccb 100644 --- a/docs/rules/Digit.md +++ b/docs/rules/Digit.md @@ -6,10 +6,10 @@ Validates whether the input contains only digits. ```php -v::digit()->validate('020 612 1851'); // false -v::digit(' ')->validate('020 612 1851'); // true -v::digit()->validate('172.655.537-21'); // false -v::digit('.', '-')->validate('172.655.537-21'); // true +v::digit()->isValid('020 612 1851'); // false +v::digit(' ')->isValid('020 612 1851'); // true +v::digit()->isValid('172.655.537-21'); // false +v::digit('.', '-')->isValid('172.655.537-21'); // true ``` ## Categorization diff --git a/docs/rules/Directory.md b/docs/rules/Directory.md index afcc8d9bc..dd5226fb0 100644 --- a/docs/rules/Directory.md +++ b/docs/rules/Directory.md @@ -5,15 +5,15 @@ Validates if the given path is a directory. ```php -v::directory()->validate(__DIR__); // true -v::directory()->validate(__FILE__); // false +v::directory()->isValid(__DIR__); // true +v::directory()->isValid(__FILE__); // false ``` This validator will consider SplFileInfo instances, so you can do something like: ```php -v::directory()->validate(new SplFileInfo('library/')); -v::directory()->validate(dir('/')); +v::directory()->isValid(new SplFileInfo('library/')); +v::directory()->isValid(dir('/')); ``` ## Categorization diff --git a/docs/rules/Domain.md b/docs/rules/Domain.md index a22386b0b..9cf2d193d 100644 --- a/docs/rules/Domain.md +++ b/docs/rules/Domain.md @@ -6,14 +6,14 @@ Validates whether the input is a valid domain name or not. ```php -v::domain()->validate('google.com'); +v::domain()->isValid('google.com'); ``` You can skip *top level domain* (TLD) checks to validate internal domain names: ```php -v::domain(false)->validate('dev.machine.local'); +v::domain(false)->isValid('dev.machine.local'); ``` This is a composite validator, it validates several rules diff --git a/docs/rules/Each.md b/docs/rules/Each.md index 8d86a8c5c..cb57ffd03 100644 --- a/docs/rules/Each.md +++ b/docs/rules/Each.md @@ -11,13 +11,13 @@ $releaseDates = [ 'relational' => '2011-02-05', ]; -v::each(v::dateTime())->validate($releaseDates); // true +v::each(v::dateTime())->isValid($releaseDates); // true ``` You can also validate array keys combining this rule with [Call](Call.md): ```php -v::call('array_keys', v::each(v::stringType()))->validate($releaseDates); // true +v::call('array_keys', v::each(v::stringType()))->isValid($releaseDates); // true ``` ## Note diff --git a/docs/rules/Email.md b/docs/rules/Email.md index 30283f3f0..8f8587ec4 100644 --- a/docs/rules/Email.md +++ b/docs/rules/Email.md @@ -5,7 +5,7 @@ Validates an email address. ```php -v::email()->validate('alganet@gmail.com'); // true +v::email()->isValid('alganet@gmail.com'); // true ``` diff --git a/docs/rules/EndsWith.md b/docs/rules/EndsWith.md index f7b956680..01b167800 100644 --- a/docs/rules/EndsWith.md +++ b/docs/rules/EndsWith.md @@ -9,13 +9,13 @@ only if the value is at the end of the input. For strings: ```php -v::endsWith('ipsum')->validate('lorem ipsum'); // true +v::endsWith('ipsum')->isValid('lorem ipsum'); // true ``` For arrays: ```php -v::endsWith('ipsum')->validate(['lorem', 'ipsum']); // true +v::endsWith('ipsum')->isValid(['lorem', 'ipsum']); // true ``` A second parameter may be passed for identical comparison instead diff --git a/docs/rules/Equals.md b/docs/rules/Equals.md index f26cb9397..254ab3d87 100644 --- a/docs/rules/Equals.md +++ b/docs/rules/Equals.md @@ -5,7 +5,7 @@ Validates if the input is equal to some value. ```php -v::equals('alganet')->validate('alganet'); // true +v::equals('alganet')->isValid('alganet'); // true ``` Message template for this validator includes `{{compareTo}}`. diff --git a/docs/rules/Equivalent.md b/docs/rules/Equivalent.md index 86fa50fc5..eb99e15ee 100644 --- a/docs/rules/Equivalent.md +++ b/docs/rules/Equivalent.md @@ -5,9 +5,9 @@ Validates if the input is equivalent to some value. ```php -v::equivalent(1)->validate(true); // true -v::equivalent('Something')->validate('someThing'); // true -v::equivalent(new ArrayObject([1, 2, 3, 4, 5]))->validate(new ArrayObject([1, 2, 3, 4, 5])); // true +v::equivalent(1)->isValid(true); // true +v::equivalent('Something')->isValid('someThing'); // true +v::equivalent(new ArrayObject([1, 2, 3, 4, 5]))->isValid(new ArrayObject([1, 2, 3, 4, 5])); // true ``` This rule is very similar to [Equals](Equals.md) but it does not make case-sensitive diff --git a/docs/rules/Even.md b/docs/rules/Even.md index 572f2622c..b6d3d92dd 100644 --- a/docs/rules/Even.md +++ b/docs/rules/Even.md @@ -5,7 +5,7 @@ Validates whether the input is an even number or not. ```php -v::intVal()->even()->validate(2); // true +v::intVal()->even()->isValid(2); // true ``` Using `int()` before `even()` is a best practice. diff --git a/docs/rules/Executable.md b/docs/rules/Executable.md index 5fc6dedcd..7e2b3808d 100644 --- a/docs/rules/Executable.md +++ b/docs/rules/Executable.md @@ -5,7 +5,7 @@ Validates if a file is an executable. ```php -v::executable()->validate('script.sh'); // true +v::executable()->isValid('script.sh'); // true ``` ## Categorization diff --git a/docs/rules/Exists.md b/docs/rules/Exists.md index e45d65bd8..33c1562d3 100644 --- a/docs/rules/Exists.md +++ b/docs/rules/Exists.md @@ -5,14 +5,14 @@ Validates files or directories. ```php -v::exists()->validate(__FILE__); // true -v::exists()->validate(__DIR__); // true +v::exists()->isValid(__FILE__); // true +v::exists()->isValid(__DIR__); // true ``` This validator will consider SplFileInfo instances, so you can do something like: ```php -v::exists()->validate(new SplFileInfo('file.txt')); +v::exists()->isValid(new SplFileInfo('file.txt')); ``` ## Categorization diff --git a/docs/rules/Extension.md b/docs/rules/Extension.md index c51a9e324..c0e7d573c 100644 --- a/docs/rules/Extension.md +++ b/docs/rules/Extension.md @@ -5,7 +5,7 @@ Validates if the file extension matches the expected one: ```php -v::extension('png')->validate('image.png'); // true +v::extension('png')->isValid('image.png'); // true ``` This rule is case-sensitive. diff --git a/docs/rules/Factor.md b/docs/rules/Factor.md index 66ff9cb7d..510d7e4a2 100644 --- a/docs/rules/Factor.md +++ b/docs/rules/Factor.md @@ -5,9 +5,9 @@ Validates if the input is a factor of the defined dividend. ```php -v::factor(0)->validate(5); // true -v::factor(4)->validate(2); // true -v::factor(4)->validate(3); // false +v::factor(0)->isValid(5); // true +v::factor(4)->isValid(2); // true +v::factor(4)->isValid(3); // false ``` ## Categorization diff --git a/docs/rules/FalseVal.md b/docs/rules/FalseVal.md index 1862fc60d..5bbc522ed 100644 --- a/docs/rules/FalseVal.md +++ b/docs/rules/FalseVal.md @@ -5,14 +5,14 @@ Validates if a value is considered as `false`. ```php -v::falseVal()->validate(false); // true -v::falseVal()->validate(0); // true -v::falseVal()->validate('0'); // true -v::falseVal()->validate('false'); // true -v::falseVal()->validate('off'); // true -v::falseVal()->validate('no'); // true -v::falseVal()->validate('0.5'); // false -v::falseVal()->validate('2'); // false +v::falseVal()->isValid(false); // true +v::falseVal()->isValid(0); // true +v::falseVal()->isValid('0'); // true +v::falseVal()->isValid('false'); // true +v::falseVal()->isValid('off'); // true +v::falseVal()->isValid('no'); // true +v::falseVal()->isValid('0.5'); // false +v::falseVal()->isValid('2'); // false ``` ## Categorization diff --git a/docs/rules/Fibonacci.md b/docs/rules/Fibonacci.md index b98cd1783..2faf47295 100644 --- a/docs/rules/Fibonacci.md +++ b/docs/rules/Fibonacci.md @@ -5,9 +5,9 @@ Validates whether the input follows the Fibonacci integer sequence. ```php -v::fibonacci()->validate(1); // true -v::fibonacci()->validate('34'); // true -v::fibonacci()->validate(6); // false +v::fibonacci()->isValid(1); // true +v::fibonacci()->isValid('34'); // true +v::fibonacci()->isValid(6); // false ``` ## Categorization diff --git a/docs/rules/File.md b/docs/rules/File.md index 70bedf934..2bc74f42d 100644 --- a/docs/rules/File.md +++ b/docs/rules/File.md @@ -5,14 +5,14 @@ Validates whether file input is as a regular filename. ```php -v::file()->validate(__FILE__); // true -v::file()->validate(__DIR__); // false +v::file()->isValid(__FILE__); // true +v::file()->isValid(__DIR__); // false ``` This validator will consider SplFileInfo instances, so you can do something like: ```php -v::file()->validate(new SplFileInfo('file.txt')); +v::file()->isValid(new SplFileInfo('file.txt')); ``` ## Categorization diff --git a/docs/rules/FilterVar.md b/docs/rules/FilterVar.md index 1a6798f21..20e40d9b0 100644 --- a/docs/rules/FilterVar.md +++ b/docs/rules/FilterVar.md @@ -6,12 +6,12 @@ Validates the input with the PHP's [filter_var()](http://php.net/filter_var) function. ```php -v::filterVar(FILTER_VALIDATE_EMAIL)->validate('bob@example.com'); // true -v::filterVar(FILTER_VALIDATE_URL)->validate('http://example.com'); // true -v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com'); // false -v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com/path'); // true -v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->validate('webserver.local'); // true -v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->validate('@local'); // false +v::filterVar(FILTER_VALIDATE_EMAIL)->isValid('bob@example.com'); // true +v::filterVar(FILTER_VALIDATE_URL)->isValid('http://example.com'); // true +v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->isValid('http://example.com'); // false +v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->isValid('http://example.com/path'); // true +v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->isValid('webserver.local'); // true +v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->isValid('@local'); // false ``` ## Categorization @@ -22,7 +22,7 @@ v::filterVar(FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)->validate('@local'); Version | Description ---------|------------- - 2.3.0 | `v::filterVar(FILTER_VALIDATE_INT)->validate(0)` is no longer false + 2.3.0 | `v::filterVar(FILTER_VALIDATE_INT)->isValid(0)` is no longer false 2.0.15 | Allow validating domains 0.8.0 | Created diff --git a/docs/rules/Finite.md b/docs/rules/Finite.md index 5ac0844fd..a0d4051ac 100644 --- a/docs/rules/Finite.md +++ b/docs/rules/Finite.md @@ -5,8 +5,8 @@ Validates if the input is a finite number. ```php -v::finite()->validate('10'); // true -v::finite()->validate(10); // true +v::finite()->isValid('10'); // true +v::finite()->isValid(10); // true ``` ## Categorization diff --git a/docs/rules/FloatType.md b/docs/rules/FloatType.md index b54b919b7..a433ec1e5 100644 --- a/docs/rules/FloatType.md +++ b/docs/rules/FloatType.md @@ -5,9 +5,9 @@ Validates whether the type of the input is [float](http://php.net/types.float). ```php -v::floatType()->validate(1.5); // true -v::floatType()->validate('1.5'); // false -v::floatType()->validate(0e5); // true +v::floatType()->isValid(1.5); // true +v::floatType()->isValid('1.5'); // false +v::floatType()->isValid(0e5); // true ``` ## Categorization diff --git a/docs/rules/FloatVal.md b/docs/rules/FloatVal.md index 7ed9574f7..a55c2151b 100644 --- a/docs/rules/FloatVal.md +++ b/docs/rules/FloatVal.md @@ -5,8 +5,8 @@ Validate whether the input value is float. ```php -v::floatVal()->validate(1.5); // true -v::floatVal()->validate('1e5'); // true +v::floatVal()->isValid(1.5); // true +v::floatVal()->isValid('1e5'); // true ``` ## Categorization diff --git a/docs/rules/Graph.md b/docs/rules/Graph.md index 725dacb46..935974f6a 100644 --- a/docs/rules/Graph.md +++ b/docs/rules/Graph.md @@ -7,7 +7,7 @@ Validates if all characters in the input are printable and actually creates visible output (no white space). ```php -v::graph()->validate('LKM@#$%4;'); // true +v::graph()->isValid('LKM@#$%4;'); // true ``` ## Categorization diff --git a/docs/rules/GreaterThan.md b/docs/rules/GreaterThan.md index 901156b1c..9b656cb5f 100644 --- a/docs/rules/GreaterThan.md +++ b/docs/rules/GreaterThan.md @@ -5,8 +5,8 @@ Validates whether the input is greater than a value. ```php -v::greaterThan(10)->validate(11); // true -v::greaterThan(10)->validate(9); // false +v::greaterThan(10)->isValid(11); // true +v::greaterThan(10)->isValid(9); // false ``` Validation makes comparison easier, check out our supported diff --git a/docs/rules/GreaterThanOrEqual.md b/docs/rules/GreaterThanOrEqual.md index 860418ea2..9ba914d42 100644 --- a/docs/rules/GreaterThanOrEqual.md +++ b/docs/rules/GreaterThanOrEqual.md @@ -5,9 +5,9 @@ Validates whether the input is greater than or equal to a value. ```php -v::intVal()->greaterThanOrEqual(10)->validate(9); // false -v::intVal()->greaterThanOrEqual(10)->validate(10); // true -v::intVal()->greaterThanOrEqual(10)->validate(11); // true +v::intVal()->greaterThanOrEqual(10)->isValid(9); // false +v::intVal()->greaterThanOrEqual(10)->isValid(10); // true +v::intVal()->greaterThanOrEqual(10)->isValid(11); // true ``` Validation makes comparison easier, check out our supported diff --git a/docs/rules/Hetu.md b/docs/rules/Hetu.md index 7b81c1523..b457a803e 100644 --- a/docs/rules/Hetu.md +++ b/docs/rules/Hetu.md @@ -5,11 +5,11 @@ Validates a Finnish personal identity code ([HETU][]). ```php -v::hetu()->validate('010106A9012'); // true -v::hetu()->validate('290199-907A'); // true -v::hetu()->validate('280291+923X'); // true +v::hetu()->isValid('010106A9012'); // true +v::hetu()->isValid('290199-907A'); // true +v::hetu()->isValid('280291+923X'); // true -v::hetu()->validate('010106_9012'); // false +v::hetu()->isValid('010106_9012'); // false ``` The validation is case-sensitive. diff --git a/docs/rules/HexRgbColor.md b/docs/rules/HexRgbColor.md index e754de0f9..edc24c76f 100644 --- a/docs/rules/HexRgbColor.md +++ b/docs/rules/HexRgbColor.md @@ -5,10 +5,10 @@ Validates weather the input is a hex RGB color or not. ```php -v::hexRgbColor()->validate('#FFFAAA'); // true -v::hexRgbColor()->validate('#ff6600'); // true -v::hexRgbColor()->validate('123123'); // true -v::hexRgbColor()->validate('FCD'); // true +v::hexRgbColor()->isValid('#FFFAAA'); // true +v::hexRgbColor()->isValid('#ff6600'); // true +v::hexRgbColor()->isValid('123123'); // true +v::hexRgbColor()->isValid('FCD'); // true ``` ## Categorization diff --git a/docs/rules/Iban.md b/docs/rules/Iban.md index 4625a82ae..f592af340 100644 --- a/docs/rules/Iban.md +++ b/docs/rules/Iban.md @@ -6,12 +6,12 @@ Validates whether the input is a valid [IBAN][] (International Bank Account Number) or not. ```php -v::iban()->validate('SE35 5000 0000 0549 1000 0003'); // true -v::iban()->validate('ch9300762011623852957'); // true +v::iban()->isValid('SE35 5000 0000 0549 1000 0003'); // true +v::iban()->isValid('ch9300762011623852957'); // true -v::iban()->validate('ZZ32 5000 5880 7742'); // false -v::iban()->validate(123456789); // false -v::iban()->validate(''); // false +v::iban()->isValid('ZZ32 5000 5880 7742'); // false +v::iban()->isValid(123456789); // false +v::iban()->isValid(''); // false ``` ## Categorization diff --git a/docs/rules/Identical.md b/docs/rules/Identical.md index fe1817003..7c18ed972 100644 --- a/docs/rules/Identical.md +++ b/docs/rules/Identical.md @@ -5,8 +5,8 @@ Validates if the input is identical to some value. ```php -v::identical(42)->validate(42); // true -v::identical(42)->validate('42'); // false +v::identical(42)->isValid(42); // true +v::identical(42)->isValid('42'); // false ``` Message template for this validator includes `{{compareTo}}`. diff --git a/docs/rules/Image.md b/docs/rules/Image.md index 71cd37a33..c6f764336 100644 --- a/docs/rules/Image.md +++ b/docs/rules/Image.md @@ -6,9 +6,9 @@ Validates if the file is a valid image by checking its MIME type. ```php -v::image()->validate('image.gif'); // true -v::image()->validate('image.jpg'); // true -v::image()->validate('image.png'); // true +v::image()->isValid('image.gif'); // true +v::image()->isValid('image.jpg'); // true +v::image()->isValid('image.png'); // true ``` All the validations above must return `false` if the input is not a valid file diff --git a/docs/rules/Imei.md b/docs/rules/Imei.md index c70034d66..45af3b9ea 100644 --- a/docs/rules/Imei.md +++ b/docs/rules/Imei.md @@ -5,8 +5,8 @@ Validates is the input is a valid [IMEI][]. ```php -v::imei()->validate('35-209900-176148-1'); // true -v::imei()->validate('490154203237518'); // true +v::imei()->isValid('35-209900-176148-1'); // true +v::imei()->isValid('490154203237518'); // true ``` ## Categorization diff --git a/docs/rules/In.md b/docs/rules/In.md index 1669dbcbf..8f18da76c 100644 --- a/docs/rules/In.md +++ b/docs/rules/In.md @@ -8,13 +8,13 @@ Validates if the input is contained in a specific haystack. For strings: ```php -v::in('lorem ipsum')->validate('ipsum'); // true +v::in('lorem ipsum')->isValid('ipsum'); // true ``` For arrays: ```php -v::in(['lorem', 'ipsum'])->validate('lorem'); // true +v::in(['lorem', 'ipsum'])->isValid('lorem'); // true ``` A second parameter may be passed for identical comparison instead diff --git a/docs/rules/Infinite.md b/docs/rules/Infinite.md index 6c956931a..30456dc02 100644 --- a/docs/rules/Infinite.md +++ b/docs/rules/Infinite.md @@ -5,7 +5,7 @@ Validates if the input is an infinite number. ```php -v::infinite()->validate(INF); // true +v::infinite()->isValid(INF); // true ``` ## Categorization diff --git a/docs/rules/Instance.md b/docs/rules/Instance.md index 9ad971dc3..976c093be 100644 --- a/docs/rules/Instance.md +++ b/docs/rules/Instance.md @@ -5,8 +5,8 @@ Validates if the input is an instance of the given class or interface. ```php -v::instance('DateTime')->validate(new DateTime); // true -v::instance('Traversable')->validate(new ArrayObject); // true +v::instance('DateTime')->isValid(new DateTime); // true +v::instance('Traversable')->isValid(new ArrayObject); // true ``` Message template for this validator includes `{{instanceName}}`. diff --git a/docs/rules/IntType.md b/docs/rules/IntType.md index 87069a796..3b1c3a48e 100644 --- a/docs/rules/IntType.md +++ b/docs/rules/IntType.md @@ -5,8 +5,8 @@ Validates whether the type of the input is [integer](http://php.net/types.integer). ```php -v::intType()->validate(42); // true -v::intType()->validate('10'); // false +v::intType()->isValid(42); // true +v::intType()->isValid('10'); // false ``` ## Categorization diff --git a/docs/rules/IntVal.md b/docs/rules/IntVal.md index 70ae3372a..e7ce83e86 100644 --- a/docs/rules/IntVal.md +++ b/docs/rules/IntVal.md @@ -5,11 +5,11 @@ Validates if the input is an integer, allowing leading zeros and other number bases. ```php -v::intVal()->validate('10'); // true -v::intVal()->validate('089'); // true -v::intVal()->validate(10); // true -v::intVal()->validate(0b101010); // true -v::intVal()->validate(0x2a); // true +v::intVal()->isValid('10'); // true +v::intVal()->isValid('089'); // true +v::intVal()->isValid(10); // true +v::intVal()->isValid(0b101010); // true +v::intVal()->isValid(0x2a); // true ``` This rule will consider as valid any input that PHP can convert to an integer, @@ -17,8 +17,8 @@ but that does not contain non-integer values. That way, one can safely use the value this rule validates, without having surprises. ```php -v::intVal()->validate(true); // false -v::intVal()->validate('89a'); // false +v::intVal()->isValid(true); // false +v::intVal()->isValid('89a'); // false ``` Even though PHP can cast the values above as integers, this rule will not diff --git a/docs/rules/Ip.md b/docs/rules/Ip.md index 94620d9c9..169284ed5 100644 --- a/docs/rules/Ip.md +++ b/docs/rules/Ip.md @@ -9,28 +9,28 @@ Validates whether the input is a valid IP address. This validator uses the native [filter_var()][] PHP function. ```php -v::ip()->validate('127.0.0.1'); // true -v::ip('220.78.168.0/21')->validate('220.78.173.2'); // true -v::ip('220.78.168.0/21')->validate('220.78.176.2'); // false +v::ip()->isValid('127.0.0.1'); // true +v::ip('220.78.168.0/21')->isValid('220.78.173.2'); // true +v::ip('220.78.168.0/21')->isValid('220.78.176.2'); // false ``` Validating ranges: ```php -v::ip('127.0.0.1-127.0.0.5')->validate('127.0.0.2'); // true -v::ip('127.0.0.1-127.0.0.5')->validate('127.0.0.10'); // false +v::ip('127.0.0.1-127.0.0.5')->isValid('127.0.0.2'); // true +v::ip('127.0.0.1-127.0.0.5')->isValid('127.0.0.10'); // false ``` You can pass a parameter with [filter_var()][] flags for IP. ```php -v::ip('*', FILTER_FLAG_NO_PRIV_RANGE)->validate('192.168.0.1'); // false +v::ip('*', FILTER_FLAG_NO_PRIV_RANGE)->isValid('192.168.0.1'); // false ``` If you want to validate IPv6 you can do as follow: ```php -v::ip('*', FILTER_FLAG_IPV6)->validate('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'); // true +v::ip('*', FILTER_FLAG_IPV6)->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'); // true ``` ## Categorization diff --git a/docs/rules/Isbn.md b/docs/rules/Isbn.md index 4501ea8b4..12e8cecff 100644 --- a/docs/rules/Isbn.md +++ b/docs/rules/Isbn.md @@ -5,10 +5,10 @@ Validates whether the input is a valid [ISBN][] or not. ```php -v::isbn()->validate('ISBN-13: 978-0-596-52068-7'); // true -v::isbn()->validate('978 0 596 52068 7'); // true -v::isbn()->validate('ISBN-12: 978-0-596-52068-7'); // false -v::isbn()->validate('978 10 596 52068 7'); // false +v::isbn()->isValid('ISBN-13: 978-0-596-52068-7'); // true +v::isbn()->isValid('978 0 596 52068 7'); // true +v::isbn()->isValid('ISBN-12: 978-0-596-52068-7'); // false +v::isbn()->isValid('978 10 596 52068 7'); // false ``` ## Categorization diff --git a/docs/rules/IterableType.md b/docs/rules/IterableType.md index d648862ef..1f0a1e0d0 100644 --- a/docs/rules/IterableType.md +++ b/docs/rules/IterableType.md @@ -5,11 +5,11 @@ Validates whether the input is iterable, meaning that it matches the built-in compile time type alias `iterable`. ```php -v::iterableType()->validate([]); // true -v::iterableType()->validate(new ArrayObject()); // true +v::iterableType()->isValid([]); // true +v::iterableType()->isValid(new ArrayObject()); // true -v::iterableType()->validate(new stdClass()); // false -v::iterableType()->validate('string'); // false +v::iterableType()->isValid(new stdClass()); // false +v::iterableType()->isValid('string'); // false ``` ## Categorization diff --git a/docs/rules/IterableVal.md b/docs/rules/IterableVal.md index 95c844be8..2954fddf3 100644 --- a/docs/rules/IterableVal.md +++ b/docs/rules/IterableVal.md @@ -5,10 +5,10 @@ Validates whether the input is an iterable value, in other words, if you can iterate over it with the [foreach][] language construct. ```php -v::iterableVal()->validate([]); // true -v::iterableVal()->validate(new ArrayObject()); // true -v::iterableVal()->validate(new stdClass()); // true -v::iterableVal()->validate('string'); // false +v::iterableVal()->isValid([]); // true +v::iterableVal()->isValid(new ArrayObject()); // true +v::iterableVal()->isValid(new stdClass()); // true +v::iterableVal()->isValid('string'); // false ``` ## Note diff --git a/docs/rules/Json.md b/docs/rules/Json.md index e9007d999..e9c1cf5e1 100644 --- a/docs/rules/Json.md +++ b/docs/rules/Json.md @@ -5,7 +5,7 @@ Validates if the given input is a valid JSON. ```php -v::json()->validate('{"foo":"bar"}'); // true +v::json()->isValid('{"foo":"bar"}'); // true ``` ## Categorization diff --git a/docs/rules/Key.md b/docs/rules/Key.md index 289dc2a4b..7c933090c 100644 --- a/docs/rules/Key.md +++ b/docs/rules/Key.md @@ -5,11 +5,11 @@ Validates the value of an array against a given rule. ```php -v::key('name', v::stringType())->validate(['name' => 'The Respect Panda']); // true +v::key('name', v::stringType())->isValid(['name' => 'The Respect Panda']); // true -v::key('email', v::email())->validate(['email' => 'therespectpanda@gmail.com']); // true +v::key('email', v::email())->isValid(['email' => 'therespectpanda@gmail.com']); // true -v::key('age', v::intVal())->validate([]); // false +v::key('age', v::intVal())->isValid([]); // false ``` You can also use `Key` to validate nested arrays: @@ -18,7 +18,7 @@ You can also use `Key` to validate nested arrays: v::key( 'payment_details', v::key('credit_card', v::creditCard()) -)->validate([ +)->isValid([ 'payment_details' => [ 'credit_card' => '5376 7473 9720 8720', ], diff --git a/docs/rules/KeyExists.md b/docs/rules/KeyExists.md index d6f367d1b..1503bfa2e 100644 --- a/docs/rules/KeyExists.md +++ b/docs/rules/KeyExists.md @@ -5,14 +5,14 @@ Validates if the given key exists in an array. ```php -v::keyExists('name')->validate(['name' => 'The Respect Panda']); // true -v::keyExists('name')->validate(['email' => 'therespectpanda@gmail.com']); // false +v::keyExists('name')->isValid(['name' => 'The Respect Panda']); // true +v::keyExists('name')->isValid(['email' => 'therespectpanda@gmail.com']); // false -v::keyExists(0)->validate(['a', 'b', 'c']); // true -v::keyExists(4)->validate(['a', 'b', 'c']); // false +v::keyExists(0)->isValid(['a', 'b', 'c']); // true +v::keyExists(4)->isValid(['a', 'b', 'c']); // false -v::keyExists('username')->validate(new ArrayObject(['username' => 'therespectpanda'])); // true -v::keyExists(5)->validate(new ArrayObject(['a', 'b', 'c'])); // false +v::keyExists('username')->isValid(new ArrayObject(['username' => 'therespectpanda'])); // true +v::keyExists(5)->isValid(new ArrayObject(['a', 'b', 'c'])); // false ``` ## Notes diff --git a/docs/rules/KeyOptional.md b/docs/rules/KeyOptional.md index 60dad7f89..35a350b0a 100644 --- a/docs/rules/KeyOptional.md +++ b/docs/rules/KeyOptional.md @@ -5,13 +5,13 @@ Validates the value of an array against a given rule when the key exists. ```php -v::keyOptional('name', v::stringType())->validate([]); // true -v::keyOptional('name', v::stringType())->validate(['name' => 'The Respect Panda']); // true +v::keyOptional('name', v::stringType())->isValid([]); // true +v::keyOptional('name', v::stringType())->isValid(['name' => 'The Respect Panda']); // true -v::keyOptional('email', v::email())->validate([]); // true -v::keyOptional('email', v::email())->validate(['email' => 'therespectpanda@gmail.com']); // true +v::keyOptional('email', v::email())->isValid([]); // true +v::keyOptional('email', v::email())->isValid(['email' => 'therespectpanda@gmail.com']); // true -v::keyOptional('age', v::intVal())->validate(['age' => 'Twenty-Five']); // false +v::keyOptional('age', v::intVal())->isValid(['age' => 'Twenty-Five']); // false ``` The name of this validator is automatically set to the key name. diff --git a/docs/rules/KeySet.md b/docs/rules/KeySet.md index 0c5aee5d2..88023dc73 100644 --- a/docs/rules/KeySet.md +++ b/docs/rules/KeySet.md @@ -8,25 +8,25 @@ Validates a keys in a defined structure. v::keySet( v::keyExists('foo'), v::keyExists('bar') -)->validate(['foo' => 'whatever', 'bar' => 'something']); // true +)->isValid(['foo' => 'whatever', 'bar' => 'something']); // true ``` It will validate the keys in the array with the rules passed in the constructor. ```php v::keySet( v::key('foo', v::intVal()) -)->validate(['foo' => 42]); // true +)->isValid(['foo' => 42]); // true v::keySet( v::key('foo', v::intVal()) -)->validate(['foo' => 'string']); // false +)->isValid(['foo' => 'string']); // false ``` Extra keys are not allowed: ```php v::keySet( v::key('foo', v::intVal()) -)->validate(['foo' => 42, 'bar' => 'String']); // false +)->isValid(['foo' => 42, 'bar' => 'String']); // false ``` Missing required keys are not allowed: @@ -35,7 +35,7 @@ v::keySet( v::key('foo', v::intVal()), v::key('bar', v::stringType()), v::key('baz', v::boolType()) -)->validate(['foo' => 42, 'bar' => 'String']); // false +)->isValid(['foo' => 42, 'bar' => 'String']); // false ``` Missing non-required keys are allowed: @@ -44,7 +44,7 @@ v::keySet( v::key('foo', v::intVal()), v::key('bar', v::stringType()), v::keyOptional('baz', v::boolType()) -)->validate(['foo' => 42, 'bar' => 'String']); // true +)->isValid(['foo' => 42, 'bar' => 'String']); // true ``` Alternatively, you can pass a chain of key-related rules to `keySet()`: @@ -54,7 +54,7 @@ v::keySet( ->key('foo', v::intVal()) ->key('bar', v::stringType()) ->keyOptional('baz', v::boolType()) -)->validate(['foo' => 42, 'bar' => 'String']); // true +)->isValid(['foo' => 42, 'bar' => 'String']); // true ``` It is not possible to negate `keySet()` rules with `not()`. diff --git a/docs/rules/LanguageCode.md b/docs/rules/LanguageCode.md index da60c1b82..daafd42b8 100644 --- a/docs/rules/LanguageCode.md +++ b/docs/rules/LanguageCode.md @@ -8,11 +8,11 @@ Validates whether the input is language code based on [ISO 639][]. **This rule requires [sokil/php-isocodes][] and [sokil/php-isocodes-db-only][] to be installed.** ```php -v::languageCode()->validate('pt'); // true -v::languageCode()->validate('en'); // true -v::languageCode()->validate('it'); // true -v::languageCode('alpha-3')->validate('ita'); // true -v::languageCode('alpha-3')->validate('eng'); // true +v::languageCode()->isValid('pt'); // true +v::languageCode()->isValid('en'); // true +v::languageCode()->isValid('it'); // true +v::languageCode('alpha-3')->isValid('ita'); // true +v::languageCode('alpha-3')->isValid('eng'); // true ``` This rule supports the two[ISO 639][] sets: diff --git a/docs/rules/Lazy.md b/docs/rules/Lazy.md index 466f20e07..614594ac0 100644 --- a/docs/rules/Lazy.md +++ b/docs/rules/Lazy.md @@ -8,7 +8,7 @@ This rule is particularly useful when creating rules that rely on the input. A g `confirmation` field matches the `password` field when processing data from a form. ```php -v::key('confirmation', v::equals($_POST['password'] ?? null))->validate($_POST); +v::key('confirmation', v::equals($_POST['password'] ?? null))->isValid($_POST); ``` The issue with the code is that it’s hard to reuse because you’re relying upon the input itself (`$_POST`). That means @@ -17,7 +17,7 @@ you can create a chain of rules and use it everywhere. The `lazy()` rule makes this job much simpler and more elegantly: ```php -v::lazy(static fn($input) => v::key('confirmation', v::equals($input['password'] ?? null)))->validate($_POST); +v::lazy(static fn($input) => v::key('confirmation', v::equals($input['password'] ?? null)))->isValid($_POST); ``` The code above is similar to the first example, but the biggest difference is that the creation of the rule doesn't rely diff --git a/docs/rules/LeapDate.md b/docs/rules/LeapDate.md index c2096facb..963c29e7a 100644 --- a/docs/rules/LeapDate.md +++ b/docs/rules/LeapDate.md @@ -5,7 +5,7 @@ Validates if a date is leap. ```php -v::leapDate('Y-m-d')->validate('1988-02-29'); // true +v::leapDate('Y-m-d')->isValid('1988-02-29'); // true ``` This validator accepts DateTime instances as well. The $format diff --git a/docs/rules/LeapYear.md b/docs/rules/LeapYear.md index 6e281b728..cb1db24fb 100644 --- a/docs/rules/LeapYear.md +++ b/docs/rules/LeapYear.md @@ -5,7 +5,7 @@ Validates if a year is leap. ```php -v::leapYear()->validate('1988'); // true +v::leapYear()->isValid('1988'); // true ``` This validator accepts DateTime instances as well. diff --git a/docs/rules/Length.md b/docs/rules/Length.md index 039dd65e9..96e8cbcd9 100644 --- a/docs/rules/Length.md +++ b/docs/rules/Length.md @@ -5,19 +5,19 @@ Validates the length of the given input against a given rule. ```php -v::length(v::between(1, 5))->validate('abc'); // true +v::length(v::between(1, 5))->isValid('abc'); // true -v::length(v::greaterThan(5))->validate('abcdef'); // true +v::length(v::greaterThan(5))->isValid('abcdef'); // true -v::length(v::lessThan(5))->validate('abc'); // true +v::length(v::lessThan(5))->isValid('abc'); // true ``` This rule can be used to validate the length of strings, arrays, and objects that implement the `Countable` interface. ```php -v::length(v::greaterThanOrEqual(3))->validate([1, 2, 3]); // true +v::length(v::greaterThanOrEqual(3))->isValid([1, 2, 3]); // true -v::length(v::equals(0))->validate(new SplPriorityQueue()); // true +v::length(v::equals(0))->isValid(new SplPriorityQueue()); // true ``` ## Categorization diff --git a/docs/rules/LessThan.md b/docs/rules/LessThan.md index dfe3108d9..a7fe56358 100644 --- a/docs/rules/LessThan.md +++ b/docs/rules/LessThan.md @@ -5,8 +5,8 @@ Validates whether the input is less than a value. ```php -v::lessThan(10)->validate(9); // true -v::lessThan(10)->validate(10); // false +v::lessThan(10)->isValid(9); // true +v::lessThan(10)->isValid(10); // false ``` Validation makes comparison easier, check out our supported diff --git a/docs/rules/LessThanOrEqual.md b/docs/rules/LessThanOrEqual.md index a69b75936..7134e3499 100644 --- a/docs/rules/LessThanOrEqual.md +++ b/docs/rules/LessThanOrEqual.md @@ -5,9 +5,9 @@ Validates whether the input is less than or equal to a value. ```php -v::lessThanOrEqual(10)->validate(9); // true -v::lessThanOrEqual(10)->validate(10); // true -v::lessThanOrEqual(10)->validate(11); // false +v::lessThanOrEqual(10)->isValid(9); // true +v::lessThanOrEqual(10)->isValid(10); // true +v::lessThanOrEqual(10)->isValid(11); // false ``` Validation makes comparison easier, check out our supported diff --git a/docs/rules/Lowercase.md b/docs/rules/Lowercase.md index 7d7e2370e..987764ef6 100644 --- a/docs/rules/Lowercase.md +++ b/docs/rules/Lowercase.md @@ -5,7 +5,7 @@ Validates whether the characters in the input are lowercase. ```php -v::stringType()->lowercase()->validate('xkcd'); // true +v::stringType()->lowercase()->isValid('xkcd'); // true ``` ## Categorization diff --git a/docs/rules/Luhn.md b/docs/rules/Luhn.md index e3603de7c..4f955a779 100644 --- a/docs/rules/Luhn.md +++ b/docs/rules/Luhn.md @@ -5,8 +5,8 @@ Validate whether a given input is a [Luhn][] number. ```php -v::luhn()->validate('2222400041240011'); // true -v::luhn()->validate('respect!'); // false +v::luhn()->isValid('2222400041240011'); // true +v::luhn()->isValid('respect!'); // false ``` ## Categorization diff --git a/docs/rules/MacAddress.md b/docs/rules/MacAddress.md index 26775b2e0..fa986e4c7 100644 --- a/docs/rules/MacAddress.md +++ b/docs/rules/MacAddress.md @@ -5,8 +5,8 @@ Validates whether the input is a valid MAC address. ```php -v::macAddress()->validate('00:11:22:33:44:55'); // true -v::macAddress()->validate('af-AA-22-33-44-55'); // true +v::macAddress()->isValid('00:11:22:33:44:55'); // true +v::macAddress()->isValid('af-AA-22-33-44-55'); // true ``` ## Categorization diff --git a/docs/rules/Max.md b/docs/rules/Max.md index 1cba0a25d..8aee002e4 100644 --- a/docs/rules/Max.md +++ b/docs/rules/Max.md @@ -5,14 +5,14 @@ Validates the maximum value of the input against a given rule. ```php -v::max(v::equals(30))->validate([10, 20, 30]); // true +v::max(v::equals(30))->isValid([10, 20, 30]); // true -v::max(v::between('e', 'g'))->validate(['b', 'd', 'f']); // true +v::max(v::between('e', 'g'))->isValid(['b', 'd', 'f']); // true v::max(v::greaterThan(new DateTime('today'))) - ->validate([new DateTime('yesterday'), new DateTime('tomorrow')]); // true + ->isValid([new DateTime('yesterday'), new DateTime('tomorrow')]); // true -v::max(v::greaterThan(15))->validate([4, 8, 12]); // false +v::max(v::greaterThan(15))->isValid([4, 8, 12]); // false ``` ## Note diff --git a/docs/rules/Mimetype.md b/docs/rules/Mimetype.md index bc9911c80..041048636 100644 --- a/docs/rules/Mimetype.md +++ b/docs/rules/Mimetype.md @@ -5,8 +5,8 @@ Validates if the input is a file and if its MIME type matches the expected one. ```php -v::mimetype('image/png')->validate('image.png'); // true -v::mimetype('image/jpeg')->validate('image.jpg'); // true +v::mimetype('image/png')->isValid('image.png'); // true +v::mimetype('image/jpeg')->isValid('image.jpg'); // true ``` This rule is case-sensitive and requires [fileinfo](http://php.net/fileinfo) PHP extension. diff --git a/docs/rules/Min.md b/docs/rules/Min.md index bc3a4e3ad..3d5359247 100644 --- a/docs/rules/Min.md +++ b/docs/rules/Min.md @@ -5,14 +5,14 @@ Validates the minimum value of the input against a given rule. ```php -v::min(v::equals(10))->validate([10, 20, 30]); // true +v::min(v::equals(10))->isValid([10, 20, 30]); // true -v::min(v::between('a', 'c'))->validate(['b', 'd', 'f']); // true +v::min(v::between('a', 'c'))->isValid(['b', 'd', 'f']); // true v::min(v::greaterThan(new DateTime('yesterday'))) - ->validate([new DateTime('today'), new DateTime('tomorrow')]); // true + ->isValid([new DateTime('today'), new DateTime('tomorrow')]); // true -v::min(v::lessThan(3))->validate([4, 8, 12]); // false +v::min(v::lessThan(3))->isValid([4, 8, 12]); // false ``` ## Note diff --git a/docs/rules/Multiple.md b/docs/rules/Multiple.md index 1b45d8944..0a8c7f63f 100644 --- a/docs/rules/Multiple.md +++ b/docs/rules/Multiple.md @@ -5,7 +5,7 @@ Validates if the input is a multiple of the given parameter ```php -v::intVal()->multiple(3)->validate(9); // true +v::intVal()->multiple(3)->isValid(9); // true ``` ## Categorization diff --git a/docs/rules/Negative.md b/docs/rules/Negative.md index d903ed095..293a50921 100644 --- a/docs/rules/Negative.md +++ b/docs/rules/Negative.md @@ -5,7 +5,7 @@ Validates whether the input is a negative number. ```php -v::numericVal()->negative()->validate(-15); // true +v::numericVal()->negative()->isValid(-15); // true ``` ## Categorization diff --git a/docs/rules/NfeAccessKey.md b/docs/rules/NfeAccessKey.md index b5e2e374f..19ee18203 100644 --- a/docs/rules/NfeAccessKey.md +++ b/docs/rules/NfeAccessKey.md @@ -5,7 +5,7 @@ Validates the access key of the Brazilian electronic invoice (NFe). ```php -v::nfeAccessKey()->validate('31841136830118868211870485416765268625116906'); // true +v::nfeAccessKey()->isValid('31841136830118868211870485416765268625116906'); // true ``` ## Categorization diff --git a/docs/rules/Nif.md b/docs/rules/Nif.md index 304fb19b7..8eb4a82c9 100644 --- a/docs/rules/Nif.md +++ b/docs/rules/Nif.md @@ -5,8 +5,8 @@ Validates Spain's fiscal identification number ([NIF](https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal)). ```php -v::nif()->validate('49294492H'); // true -v::nif()->validate('P6437358A'); // false +v::nif()->isValid('49294492H'); // true +v::nif()->isValid('P6437358A'); // false ``` ## Categorization diff --git a/docs/rules/Nip.md b/docs/rules/Nip.md index a902ab169..0edd20586 100644 --- a/docs/rules/Nip.md +++ b/docs/rules/Nip.md @@ -5,11 +5,11 @@ Validates whether the input is a Polish VAT identification number (NIP). ```php -v::nip()->validate('1645865777'); // true -v::nip()->validate('1645865778'); // false -v::nip()->validate('1234567890'); // false -v::nip()->validate('164-586-57-77'); // false -v::nip()->validate('164-58-65-777'); // false +v::nip()->isValid('1645865777'); // true +v::nip()->isValid('1645865778'); // false +v::nip()->isValid('1234567890'); // false +v::nip()->isValid('164-586-57-77'); // false +v::nip()->isValid('164-58-65-777'); // false ``` ## Categorization diff --git a/docs/rules/No.md b/docs/rules/No.md index aba24970c..c1c92b238 100644 --- a/docs/rules/No.md +++ b/docs/rules/No.md @@ -6,12 +6,12 @@ Validates if value is considered as "No". ```php -v::no()->validate('N'); // true -v::no()->validate('Nay'); // true -v::no()->validate('Nix'); // true -v::no()->validate('No'); // true -v::no()->validate('Nope'); // true -v::no()->validate('Not'); // true +v::no()->isValid('N'); // true +v::no()->isValid('Nay'); // true +v::no()->isValid('Nix'); // true +v::no()->isValid('No'); // true +v::no()->isValid('Nope'); // true +v::no()->isValid('Not'); // true ``` This rule is case insensitive. @@ -21,13 +21,13 @@ constant, meaning that it will validate the input using your current location: ```php setlocale(LC_ALL, 'ru_RU'); -v::no(true)->validate('нет'); // true +v::no(true)->isValid('нет'); // true ``` Be careful when using `$locale` as `TRUE` because the it's very permissive: ```php -v::no(true)->validate('Never gonna give you up 🎵'); // true +v::no(true)->isValid('Never gonna give you up 🎵'); // true ``` Besides that, with `$locale` as `TRUE` it will consider any character starting @@ -35,7 +35,7 @@ with "N" as valid: ```php setlocale(LC_ALL, 'es_ES'); -v::no(true)->validate('Yes'); // true +v::no(true)->isValid('Yes'); // true ``` ## Categorization diff --git a/docs/rules/NoWhitespace.md b/docs/rules/NoWhitespace.md index 58fe9c027..a3f9b14bb 100644 --- a/docs/rules/NoWhitespace.md +++ b/docs/rules/NoWhitespace.md @@ -5,8 +5,8 @@ Validates if a string contains no whitespace (spaces, tabs and line breaks); ```php -v::noWhitespace()->validate('foo bar'); //false -v::noWhitespace()->validate("foo\nbar"); // false +v::noWhitespace()->isValid('foo bar'); //false +v::noWhitespace()->isValid("foo\nbar"); // false ``` This is most useful when chaining with other validators such as `Alnum()` diff --git a/docs/rules/NoneOf.md b/docs/rules/NoneOf.md index 0feb393fc..6708c5c61 100644 --- a/docs/rules/NoneOf.md +++ b/docs/rules/NoneOf.md @@ -8,7 +8,7 @@ Validates if NONE of the given validators validate: v::noneOf( v::intVal(), v::floatVal() -)->validate('foo'); // true +)->isValid('foo'); // true ``` In the sample above, 'foo' isn't a integer nor a float, so noneOf returns true. diff --git a/docs/rules/Not.md b/docs/rules/Not.md index 332c3a765..b46dd501b 100644 --- a/docs/rules/Not.md +++ b/docs/rules/Not.md @@ -5,7 +5,7 @@ Negates any rule. ```php -v::not(v::ip())->validate('foo'); // true +v::not(v::ip())->isValid('foo'); // true ``` In the sample above, validator returns true because 'foo' isn't an IP Address. @@ -13,7 +13,7 @@ In the sample above, validator returns true because 'foo' isn't an IP Address. You can negate complex, grouped or chained validators as well: ```php -v::not(v::intVal()->positive())->validate(-1.5); // true +v::not(v::intVal()->positive())->isValid(-1.5); // true ``` Each other validation has custom messages for negated rules. diff --git a/docs/rules/NotBlank.md b/docs/rules/NotBlank.md index d5de96783..e6599e42f 100644 --- a/docs/rules/NotBlank.md +++ b/docs/rules/NotBlank.md @@ -6,22 +6,22 @@ Validates if the given input is not a blank value (`null`, zeros, empty strings or empty arrays, recursively). ```php -v::notBlank()->validate(null); // false -v::notBlank()->validate(''); // false -v::notBlank()->validate([]); // false -v::notBlank()->validate(' '); // false -v::notBlank()->validate(0); // false -v::notBlank()->validate('0'); // false -v::notBlank()->validate(0); // false -v::notBlank()->validate('0.0'); // false -v::notBlank()->validate(false); // false -v::notBlank()->validate(['']); // false -v::notBlank()->validate([' ']); // false -v::notBlank()->validate([0]); // false -v::notBlank()->validate(['0']); // false -v::notBlank()->validate([false]); // false -v::notBlank()->validate([[''], [0]]); // false -v::notBlank()->validate(new stdClass()); // false +v::notBlank()->isValid(null); // false +v::notBlank()->isValid(''); // false +v::notBlank()->isValid([]); // false +v::notBlank()->isValid(' '); // false +v::notBlank()->isValid(0); // false +v::notBlank()->isValid('0'); // false +v::notBlank()->isValid(0); // false +v::notBlank()->isValid('0.0'); // false +v::notBlank()->isValid(false); // false +v::notBlank()->isValid(['']); // false +v::notBlank()->isValid([' ']); // false +v::notBlank()->isValid([0]); // false +v::notBlank()->isValid(['0']); // false +v::notBlank()->isValid([false]); // false +v::notBlank()->isValid([[''], [0]]); // false +v::notBlank()->isValid(new stdClass()); // false ``` It's similar to [NotEmpty](NotEmpty.md) but it's way more strict. diff --git a/docs/rules/NotEmoji.md b/docs/rules/NotEmoji.md index 2c4020ea6..53eb5b1d0 100644 --- a/docs/rules/NotEmoji.md +++ b/docs/rules/NotEmoji.md @@ -5,12 +5,12 @@ Validates if the input does not contain an emoji. ```php -v::notEmoji()->validate('Hello World, without emoji'); // true -v::notEmoji()->validate('🍕'); // false -v::notEmoji()->validate('🎈'); // false -v::notEmoji()->validate('⚡'); // false -v::notEmoji()->validate('this is a spark ⚡'); // false -v::notEmoji()->validate('🌊🌊🌊🌊🌊🏄🌊🌊🌊🏖🌴'); // false +v::notEmoji()->isValid('Hello World, without emoji'); // true +v::notEmoji()->isValid('🍕'); // false +v::notEmoji()->isValid('🎈'); // false +v::notEmoji()->isValid('⚡'); // false +v::notEmoji()->isValid('this is a spark ⚡'); // false +v::notEmoji()->isValid('🌊🌊🌊🌊🌊🏄🌊🌊🌊🏖🌴'); // false ``` Please consider that the performance of this validator is linear which diff --git a/docs/rules/NotEmpty.md b/docs/rules/NotEmpty.md index 585e32a84..b1200221c 100644 --- a/docs/rules/NotEmpty.md +++ b/docs/rules/NotEmpty.md @@ -7,32 +7,32 @@ into account, use `noWhitespace()` if no spaces or linebreaks and other whitespace anywhere in the input is desired. ```php -v::stringType()->notEmpty()->validate(''); // false +v::stringType()->notEmpty()->isValid(''); // false ``` Null values are empty: ```php -v::notEmpty()->validate(null); // false +v::notEmpty()->isValid(null); // false ``` Numbers: ```php -v::intVal()->notEmpty()->validate(0); // false +v::intVal()->notEmpty()->isValid(0); // false ``` Empty arrays: ```php -v::arrayVal()->notEmpty()->validate([]); // false +v::arrayVal()->notEmpty()->isValid([]); // false ``` Whitespace: ```php -v::stringType()->notEmpty()->validate(' '); //false -v::stringType()->notEmpty()->validate("\t \n \r"); //false +v::stringType()->notEmpty()->isValid(' '); //false +v::stringType()->notEmpty()->isValid("\t \n \r"); //false ``` ## Categorization diff --git a/docs/rules/NotUndef.md b/docs/rules/NotUndef.md index e4be9506d..30764924a 100644 --- a/docs/rules/NotUndef.md +++ b/docs/rules/NotUndef.md @@ -6,27 +6,27 @@ Validates if the given input is not optional. By _optional_ we consider `null` or an empty string (`''`). ```php -v::notUndef()->validate(''); // false -v::notUndef()->validate(null); // false +v::notUndef()->isValid(''); // false +v::notUndef()->isValid(null); // false ``` Other values: ```php -v::notUndef()->validate([]); // true -v::notUndef()->validate(' '); // true -v::notUndef()->validate(0); // true -v::notUndef()->validate('0'); // true -v::notUndef()->validate(0); // true -v::notUndef()->validate('0.0'); // true -v::notUndef()->validate(false); // true -v::notUndef()->validate(['']); // true -v::notUndef()->validate([' ']); // true -v::notUndef()->validate([0]); // true -v::notUndef()->validate(['0']); // true -v::notUndef()->validate([false]); // true -v::notUndef()->validate([[''), [0]]); // true -v::notUndef()->validate(new stdClass()); // true +v::notUndef()->isValid([]); // true +v::notUndef()->isValid(' '); // true +v::notUndef()->isValid(0); // true +v::notUndef()->isValid('0'); // true +v::notUndef()->isValid(0); // true +v::notUndef()->isValid('0.0'); // true +v::notUndef()->isValid(false); // true +v::notUndef()->isValid(['']); // true +v::notUndef()->isValid([' ']); // true +v::notUndef()->isValid([0]); // true +v::notUndef()->isValid(['0']); // true +v::notUndef()->isValid([false]); // true +v::notUndef()->isValid([[''), [0]]); // true +v::notUndef()->isValid(new stdClass()); // true ``` ## Categorization diff --git a/docs/rules/NullType.md b/docs/rules/NullType.md index c03441d82..2df2a5fd0 100644 --- a/docs/rules/NullType.md +++ b/docs/rules/NullType.md @@ -5,7 +5,7 @@ Validates whether the input is [null](http://php.net/types.null). ```php -v::nullType()->validate(null); // true +v::nullType()->isValid(null); // true ``` ## Categorization diff --git a/docs/rules/Nullable.md b/docs/rules/Nullable.md index 4f1711290..29eb32893 100644 --- a/docs/rules/Nullable.md +++ b/docs/rules/Nullable.md @@ -5,9 +5,9 @@ Validates the given input with a defined rule when input is not NULL. ```php -v::nullable(v::email())->validate(null); // true -v::nullable(v::email())->validate('example@example.com'); // true -v::nullable(v::email())->validate('not an email'); // false +v::nullable(v::email())->isValid(null); // true +v::nullable(v::email())->isValid('example@example.com'); // true +v::nullable(v::email())->isValid('not an email'); // false ``` ## Categorization diff --git a/docs/rules/Number.md b/docs/rules/Number.md index 13c734eec..0d82f8217 100644 --- a/docs/rules/Number.md +++ b/docs/rules/Number.md @@ -5,8 +5,8 @@ Validates if the input is a number. ```php -v::number()->validate(42); // true -v::number()->validate(acos(8)); // false +v::number()->isValid(42); // true +v::number()->isValid(acos(8)); // false ``` > "In computing, NaN, standing for not a number, is a numeric data type value diff --git a/docs/rules/NumericVal.md b/docs/rules/NumericVal.md index e713f56b7..f9dc8ff1a 100644 --- a/docs/rules/NumericVal.md +++ b/docs/rules/NumericVal.md @@ -5,8 +5,8 @@ Validates whether the input is numeric. ```php -v::numericVal()->validate(-12); // true -v::numericVal()->validate('135.0'); // true +v::numericVal()->isValid(-12); // true +v::numericVal()->isValid('135.0'); // true ``` This rule doesn't validate if the input is a valid number, for that diff --git a/docs/rules/ObjectType.md b/docs/rules/ObjectType.md index e8314bca9..774f872d2 100644 --- a/docs/rules/ObjectType.md +++ b/docs/rules/ObjectType.md @@ -5,7 +5,7 @@ Validates whether the input is an [object](http://php.net/types.object). ```php -v::objectType()->validate(new stdClass); // true +v::objectType()->isValid(new stdClass); // true ``` ## Categorization diff --git a/docs/rules/Odd.md b/docs/rules/Odd.md index dafb5865b..d256077e9 100644 --- a/docs/rules/Odd.md +++ b/docs/rules/Odd.md @@ -5,8 +5,8 @@ Validates whether the input is an odd number or not. ```php -v::odd()->validate(0); // false -v::odd()->validate(3); // true +v::odd()->isValid(0); // false +v::odd()->isValid(3); // true ``` Using `intVal()` before `odd()` is a best practice. diff --git a/docs/rules/OneOf.md b/docs/rules/OneOf.md index a2cb98ea3..f606a4d62 100644 --- a/docs/rules/OneOf.md +++ b/docs/rules/OneOf.md @@ -5,10 +5,10 @@ Will validate if exactly one inner validator passes. ```php -v::oneOf(v::digit(), v::alpha())->validate('AB'); // true -v::oneOf(v::digit(), v::alpha())->validate('12'); // true -v::oneOf(v::digit(), v::alpha())->validate('AB12'); // false -v::oneOf(v::digit(), v::alpha())->validate('*'); // false +v::oneOf(v::digit(), v::alpha())->isValid('AB'); // true +v::oneOf(v::digit(), v::alpha())->isValid('12'); // true +v::oneOf(v::digit(), v::alpha())->isValid('AB12'); // false +v::oneOf(v::digit(), v::alpha())->isValid('*'); // false ``` The chains above validate if the input is either a digit or an alphabetic diff --git a/docs/rules/PerfectSquare.md b/docs/rules/PerfectSquare.md index bad1891b3..75a4818af 100644 --- a/docs/rules/PerfectSquare.md +++ b/docs/rules/PerfectSquare.md @@ -5,8 +5,8 @@ Validates whether the input is a perfect square. ```php -v::perfectSquare()->validate(25); // true (5*5) -v::perfectSquare()->validate(9); // true (3*3) +v::perfectSquare()->isValid(25); // true (5*5) +v::perfectSquare()->isValid(9); // true (3*3) ``` ## Categorization diff --git a/docs/rules/Pesel.md b/docs/rules/Pesel.md index aa9b476ab..97682637e 100644 --- a/docs/rules/Pesel.md +++ b/docs/rules/Pesel.md @@ -5,10 +5,10 @@ Validates PESEL (Polish human identification number). ```php -v::pesel()->validate('21120209256'); // true -v::pesel()->validate('97072704800'); // true -v::pesel()->validate('97072704801'); // false -v::pesel()->validate('PESEL123456'); // false +v::pesel()->isValid('21120209256'); // true +v::pesel()->isValid('97072704800'); // true +v::pesel()->isValid('97072704801'); // false +v::pesel()->isValid('PESEL123456'); // false ``` ## Categorization diff --git a/docs/rules/Phone.md b/docs/rules/Phone.md index e99787613..e678d75b9 100644 --- a/docs/rules/Phone.md +++ b/docs/rules/Phone.md @@ -7,9 +7,9 @@ the `giggsey/libphonenumber-for-php-lite` package. ```php -v::phone()->validate('+1 650 253 00 00'); // true -v::phone('BR')->validate('+55 11 91111 1111'); // true -v::phone('BR')->validate('11 91111 1111'); // false +v::phone()->isValid('+1 650 253 00 00'); // true +v::phone('BR')->isValid('+55 11 91111 1111'); // true +v::phone('BR')->isValid('11 91111 1111'); // false ``` ## Categorization diff --git a/docs/rules/PhpLabel.md b/docs/rules/PhpLabel.md index 184d07727..9b7d133be 100644 --- a/docs/rules/PhpLabel.md +++ b/docs/rules/PhpLabel.md @@ -9,9 +9,9 @@ Reference: http://php.net/manual/en/language.variables.basics.php ```php -v::phpLabel()->validate('person'); //true -v::phpLabel()->validate('foo'); //true -v::phpLabel()->validate('4ccess'); //false +v::phpLabel()->isValid('person'); //true +v::phpLabel()->isValid('foo'); //true +v::phpLabel()->isValid('4ccess'); //false ``` ## Categorization diff --git a/docs/rules/Pis.md b/docs/rules/Pis.md index 38de2d4ca..6ce926f95 100644 --- a/docs/rules/Pis.md +++ b/docs/rules/Pis.md @@ -5,11 +5,11 @@ Validates a Brazilian PIS/NIS number ignoring any non-digit char. ```php -v::pis()->validate('120.0340.678-8'); // true -v::pis()->validate('120.03406788'); // true -v::pis()->validate('120.0340.6788'); // true -v::pis()->validate('1.2.0.0.3.4.0.6.7.8.8'); // true -v::pis()->validate('12003406788'); // true +v::pis()->isValid('120.0340.678-8'); // true +v::pis()->isValid('120.03406788'); // true +v::pis()->isValid('120.0340.6788'); // true +v::pis()->isValid('1.2.0.0.3.4.0.6.7.8.8'); // true +v::pis()->isValid('12003406788'); // true ``` ## Categorization diff --git a/docs/rules/PolishIdCard.md b/docs/rules/PolishIdCard.md index 4a1187af5..01b18cd10 100644 --- a/docs/rules/PolishIdCard.md +++ b/docs/rules/PolishIdCard.md @@ -5,10 +5,10 @@ Validates whether the input is a Polish identity card (Dowód Osobisty). ```php -v::polishIdCard()->validate('AYW036733'); // true -v::polishIdCard()->validate('APH505567'); // true -v::polishIdCard()->validate('APH 505567'); // false -v::polishIdCard()->validate('AYW036731'); // false +v::polishIdCard()->isValid('AYW036733'); // true +v::polishIdCard()->isValid('APH505567'); // true +v::polishIdCard()->isValid('APH 505567'); // false +v::polishIdCard()->isValid('AYW036731'); // false ``` ## Categorization diff --git a/docs/rules/PortugueseNif.md b/docs/rules/PortugueseNif.md index 27d90f93a..b81529592 100644 --- a/docs/rules/PortugueseNif.md +++ b/docs/rules/PortugueseNif.md @@ -5,8 +5,8 @@ Validates Portugal's fiscal identification number ([NIF](https://pt.wikipedia.org/wiki/N%C3%BAmero_de_identifica%C3%A7%C3%A3o_fiscal)). ```php -v::portugueseNif()->validate('124885446'); // true -v::portugueseNif()->validate('220005245'); // false +v::portugueseNif()->isValid('124885446'); // true +v::portugueseNif()->isValid('220005245'); // false ``` ## Categorization diff --git a/docs/rules/Positive.md b/docs/rules/Positive.md index 2d8756d33..312983148 100644 --- a/docs/rules/Positive.md +++ b/docs/rules/Positive.md @@ -5,9 +5,9 @@ Validates whether the input is a positive number. ```php -v::positive()->validate(1); // true -v::positive()->validate(0); // false -v::positive()->validate(-15); // false +v::positive()->isValid(1); // true +v::positive()->isValid(0); // false +v::positive()->isValid(-15); // false ``` ## Categorization diff --git a/docs/rules/PostalCode.md b/docs/rules/PostalCode.md index 3658c693b..116be8b40 100644 --- a/docs/rules/PostalCode.md +++ b/docs/rules/PostalCode.md @@ -5,19 +5,19 @@ Validates whether the input is a valid postal code or not. ```php -v::postalCode('BR')->validate('02179000'); // true -v::postalCode('BR')->validate('02179-000'); // true -v::postalCode('US')->validate('02179-000'); // false -v::postalCode('US')->validate('55372'); // true -v::postalCode('PL')->validate('99-300'); // true +v::postalCode('BR')->isValid('02179000'); // true +v::postalCode('BR')->isValid('02179-000'); // true +v::postalCode('US')->isValid('02179-000'); // false +v::postalCode('US')->isValid('55372'); // true +v::postalCode('PL')->isValid('99-300'); // true ``` By default, `PostalCode` won't validate the format (puncts, spaces), unless you pass `$formatted = true`: ```php -v::postalCode('BR', true)->validate('02179000'); // false -v::postalCode('BR', true)->validate('02179-000'); // true +v::postalCode('BR', true)->isValid('02179000'); // false +v::postalCode('BR', true)->isValid('02179-000'); // true ``` Message template for this validator includes `{{countryCode}}`. diff --git a/docs/rules/PrimeNumber.md b/docs/rules/PrimeNumber.md index cd6669434..b3b7eee61 100644 --- a/docs/rules/PrimeNumber.md +++ b/docs/rules/PrimeNumber.md @@ -5,7 +5,7 @@ Validates a prime number ```php -v::primeNumber()->validate(7); // true +v::primeNumber()->isValid(7); // true ``` ## Categorization diff --git a/docs/rules/Printable.md b/docs/rules/Printable.md index e61473b05..9a83628fa 100644 --- a/docs/rules/Printable.md +++ b/docs/rules/Printable.md @@ -6,7 +6,7 @@ Similar to `Graph` but accepts whitespace. ```php -v::printable()->validate('LMKA0$% _123'); // true +v::printable()->isValid('LMKA0$% _123'); // true ``` ## Categorization diff --git a/docs/rules/Property.md b/docs/rules/Property.md index ceb8ba73e..ea9b648cd 100644 --- a/docs/rules/Property.md +++ b/docs/rules/Property.md @@ -9,9 +9,9 @@ $object = new stdClass; $object->name = 'The Respect Panda'; $object->email = 'therespectpanda@gmail.com'; -v::property('name', v::equals('The Respect Panda'))->validate($object); // true +v::property('name', v::equals('The Respect Panda'))->isValid($object); // true -v::property('email', v::email())->validate($object); // true +v::property('email', v::email())->isValid($object); // true v::property('email', v::email()->endsWith('@example.com'))->assert($object); // false ``` @@ -25,7 +25,7 @@ $object->address->postalCode = '1017 BS'; v::property( 'address', v::property('postalCode', v::postalCode('NL')) -)->validate($object); // true +)->isValid($object); // true ``` The name of this validator is automatically set to the property name. diff --git a/docs/rules/PropertyExists.md b/docs/rules/PropertyExists.md index 97bc9e470..1943d9745 100644 --- a/docs/rules/PropertyExists.md +++ b/docs/rules/PropertyExists.md @@ -9,9 +9,9 @@ $object = new stdClass; $object->name = 'The Respect Panda'; $object->email = 'therespectpanda@gmail.com'; -v::propertyExists('name')->validate($object); // true -v::propertyExists('email')->validate($object); // true -v::propertyExists('website')->validate($object); // false +v::propertyExists('name')->isValid($object); // true +v::propertyExists('email')->isValid($object); // true +v::propertyExists('website')->isValid($object); // false ``` ## Notes diff --git a/docs/rules/PropertyOptional.md b/docs/rules/PropertyOptional.md index 7c7ba64cf..52d1ec051 100644 --- a/docs/rules/PropertyOptional.md +++ b/docs/rules/PropertyOptional.md @@ -9,13 +9,13 @@ $object = new stdClass; $object->name = 'The Respect Panda'; $object->email = 'therespectpanda@gmail.com'; -v::propertyOptional('name', v::notEmpty())->validate($object); // true -v::propertyOptional('email', v::email())->validate($object); // true +v::propertyOptional('name', v::notEmpty())->isValid($object); // true +v::propertyOptional('email', v::email())->isValid($object); // true -v::propertyOptional('age', v::intVal())->validate($object); // true -v::propertyOptional('website', v::url())->validate($object); // true +v::propertyOptional('age', v::intVal())->isValid($object); // true +v::propertyOptional('website', v::url())->isValid($object); // true -v::propertyOptional('name', v::lowercase())->validate($object); // false +v::propertyOptional('name', v::lowercase())->isValid($object); // false ``` The name of this validator is automatically set to the property name. @@ -32,8 +32,8 @@ anything that is not an object because it will always pass when it doesn't find ensure the input is an object, use [ObjectType](ObjectType.md) with it. ```php -v::propertyOptional('name', v::notEmpty())->validate('Not an object'); // true -v::objectType()->propertyOptional('name', v::notEmpty())->validate('Not an object'); // false +v::propertyOptional('name', v::notEmpty())->isValid('Not an object'); // true +v::objectType()->propertyOptional('name', v::notEmpty())->isValid('Not an object'); // false ``` * To only validate if a property exists, use [PropertyExists](PropertyExists.md) instead. diff --git a/docs/rules/PublicDomainSuffix.md b/docs/rules/PublicDomainSuffix.md index 281f4e925..ff529ef22 100644 --- a/docs/rules/PublicDomainSuffix.md +++ b/docs/rules/PublicDomainSuffix.md @@ -5,17 +5,17 @@ Validates whether the input is a public ICANN domain suffix. ```php -v::publicDomainSuffix->validate('co.uk'); // true -v::publicDomainSuffix->validate('CO.UK'); // true -v::publicDomainSuffix->validate('nom.br'); // true -v::publicDomainSuffix->validate('invalid.com'); // false +v::publicDomainSuffix->isValid('co.uk'); // true +v::publicDomainSuffix->isValid('CO.UK'); // true +v::publicDomainSuffix->isValid('nom.br'); // true +v::publicDomainSuffix->isValid('invalid.com'); // false ``` This rule will not match top level domains such as `tk`. If you want to match either, use a combination with `Tld`: ```php -v::oneOf(v::tld(), v::publicDomainSuffix())->validate('tk'); // true +v::oneOf(v::tld(), v::publicDomainSuffix())->isValid('tk'); // true ``` ## Categorization diff --git a/docs/rules/Punct.md b/docs/rules/Punct.md index ad06a35b0..43df7c403 100644 --- a/docs/rules/Punct.md +++ b/docs/rules/Punct.md @@ -6,7 +6,7 @@ Validates whether the input composed by only punctuation characters. ```php -v::punct()->validate('&,.;[]'); // true +v::punct()->isValid('&,.;[]'); // true ``` ## Categorization diff --git a/docs/rules/Readable.md b/docs/rules/Readable.md index 53d88da3f..4332fb214 100644 --- a/docs/rules/Readable.md +++ b/docs/rules/Readable.md @@ -5,7 +5,7 @@ Validates if the given data is a file exists and is readable. ```php -v::readable()->validate('file.txt'); // true +v::readable()->isValid('file.txt'); // true ``` ## Categorization diff --git a/docs/rules/Regex.md b/docs/rules/Regex.md index 88a299788..863bde5eb 100644 --- a/docs/rules/Regex.md +++ b/docs/rules/Regex.md @@ -5,7 +5,7 @@ Validates whether the input matches a defined regular expression. ```php -v::regex('/[a-z]/')->validate('a'); // true +v::regex('/[a-z]/')->isValid('a'); // true ``` Message template for this validator includes `{{regex}}`. diff --git a/docs/rules/ResourceType.md b/docs/rules/ResourceType.md index 5aaec706d..098f0488c 100644 --- a/docs/rules/ResourceType.md +++ b/docs/rules/ResourceType.md @@ -5,7 +5,7 @@ Validates whether the input is a [resource](http://php.net/types.resource). ```php -v::resourceType()->validate(fopen('/path/to/file.txt', 'w')); // true +v::resourceType()->isValid(fopen('/path/to/file.txt', 'w')); // true ``` ## Categorization diff --git a/docs/rules/Roman.md b/docs/rules/Roman.md index 6d1271a68..394a564cc 100644 --- a/docs/rules/Roman.md +++ b/docs/rules/Roman.md @@ -5,7 +5,7 @@ Validates if the input is a Roman numeral. ```php -v::roman()->validate('IV'); // true +v::roman()->isValid('IV'); // true ``` ## Categorization diff --git a/docs/rules/ScalarVal.md b/docs/rules/ScalarVal.md index a92b975a6..b1a7270ac 100644 --- a/docs/rules/ScalarVal.md +++ b/docs/rules/ScalarVal.md @@ -5,8 +5,8 @@ Validates whether the input is a scalar value or not. ```php -v::scalarVal()->validate([]); // false -v::scalarVal()->validate(135.0); // true +v::scalarVal()->isValid([]); // false +v::scalarVal()->isValid(135.0); // true ``` ## Categorization diff --git a/docs/rules/Size.md b/docs/rules/Size.md index db325d66a..a3f39fd1a 100644 --- a/docs/rules/Size.md +++ b/docs/rules/Size.md @@ -7,9 +7,9 @@ Validates whether the input is a file that is of a certain size or not. ```php -v::size('1KB')->validate($filename); // Must have at least 1KB size -v::size('1MB', '2MB')->validate($filename); // Must have the size between 1MB and 2MB -v::size(null, '1GB')->validate($filename); // Must not be greater than 1GB +v::size('1KB')->isValid($filename); // Must have at least 1KB size +v::size('1MB', '2MB')->isValid($filename); // Must have the size between 1MB and 2MB +v::size(null, '1GB')->isValid($filename); // Must not be greater than 1GB ``` Sizes are not case-sensitive and the accepted values are: @@ -27,7 +27,7 @@ Sizes are not case-sensitive and the accepted values are: This validator will consider `SplFileInfo` instances, like: ```php -v::size('1.5mb')->validate(new SplFileInfo($filename)); // Will return true or false +v::size('1.5mb')->isValid(new SplFileInfo($filename)); // Will return true or false ``` Message template for this validator includes `{{minSize}}` and `{{maxSize}}`. diff --git a/docs/rules/Slug.md b/docs/rules/Slug.md index 983eb35de..312ec85ad 100644 --- a/docs/rules/Slug.md +++ b/docs/rules/Slug.md @@ -5,9 +5,9 @@ Validates whether the input is a valid slug. ```php -v::slug()->validate('my-wordpress-title'); // true -v::slug()->validate('my-wordpress--title'); // false -v::slug()->validate('my-wordpress-title-'); // false +v::slug()->isValid('my-wordpress-title'); // true +v::slug()->isValid('my-wordpress--title'); // false +v::slug()->isValid('my-wordpress-title-'); // false ``` ## Categorization diff --git a/docs/rules/Sorted.md b/docs/rules/Sorted.md index d1162413c..4eb4cb96e 100644 --- a/docs/rules/Sorted.md +++ b/docs/rules/Sorted.md @@ -5,11 +5,11 @@ Validates whether the input is sorted in a certain order or not. ```php -v::sorted('ASC')->validate([1, 2, 3]); // true -v::sorted('ASC')->validate('ABC'); // true -v::sorted('DESC')->validate([3, 2, 1]); // true -v::sorted('ASC')->validate([]); // true -v::sorted('ASC')->validate([1]); // true +v::sorted('ASC')->isValid([1, 2, 3]); // true +v::sorted('ASC')->isValid('ABC'); // true +v::sorted('DESC')->isValid([3, 2, 1]); // true +v::sorted('ASC')->isValid([]); // true +v::sorted('ASC')->isValid([1]); // true ``` You can also combine [Call](Call.md) to create custom validations: @@ -20,15 +20,15 @@ v::call( return array_column($input, 'key'); }, v::sorted('ASC') - )->validate([ + )->isValid([ ['key' => 1], ['key' => 5], ['key' => 9], ]); // true -v::call('strval', v::sorted('DESC'))->validate(4321); // true +v::call('strval', v::sorted('DESC'))->isValid(4321); // true -v::call('iterator_to_array', v::sorted())->validate(new ArrayIterator([1, 7, 4])); // false +v::call('iterator_to_array', v::sorted())->isValid(new ArrayIterator([1, 7, 4])); // false ``` ## Categorization diff --git a/docs/rules/Space.md b/docs/rules/Space.md index f0081dfc4..14ab059f0 100644 --- a/docs/rules/Space.md +++ b/docs/rules/Space.md @@ -6,7 +6,7 @@ Validates whether the input contains only whitespaces characters. ```php -v::space()->validate(' '); // true +v::space()->isValid(' '); // true ``` ## Categorization diff --git a/docs/rules/StartsWith.md b/docs/rules/StartsWith.md index 38138d256..f206da277 100644 --- a/docs/rules/StartsWith.md +++ b/docs/rules/StartsWith.md @@ -11,13 +11,13 @@ if the value is at the beginning of the input. For strings: ```php -v::startsWith('lorem')->validate('lorem ipsum'); // true +v::startsWith('lorem')->isValid('lorem ipsum'); // true ``` For arrays: ```php -v::startsWith('lorem')->validate(['lorem', 'ipsum']); // true +v::startsWith('lorem')->isValid(['lorem', 'ipsum']); // true ``` `true` may be passed as a parameter to indicate identical comparison diff --git a/docs/rules/StringType.md b/docs/rules/StringType.md index 5191e4dd1..84535d159 100644 --- a/docs/rules/StringType.md +++ b/docs/rules/StringType.md @@ -5,7 +5,7 @@ Validates whether the type of an input is string or not. ```php -v::stringType()->validate('hi'); // true +v::stringType()->isValid('hi'); // true ``` ## Categorization diff --git a/docs/rules/StringVal.md b/docs/rules/StringVal.md index c1707b59d..64478a5e9 100644 --- a/docs/rules/StringVal.md +++ b/docs/rules/StringVal.md @@ -5,13 +5,13 @@ Validates whether the input can be used as a string. ```php -v::stringVal()->validate('6'); // true -v::stringVal()->validate('String'); // true -v::stringVal()->validate(1.0); // true -v::stringVal()->validate(42); // true -v::stringVal()->validate(false); // true -v::stringVal()->validate(true); // true -v::stringVal()->validate(new ClassWithToString()); // true if ClassWithToString implements `__toString` +v::stringVal()->isValid('6'); // true +v::stringVal()->isValid('String'); // true +v::stringVal()->isValid(1.0); // true +v::stringVal()->isValid(42); // true +v::stringVal()->isValid(false); // true +v::stringVal()->isValid(true); // true +v::stringVal()->isValid(new ClassWithToString()); // true if ClassWithToString implements `__toString` ``` ## Categorization diff --git a/docs/rules/SubdivisionCode.md b/docs/rules/SubdivisionCode.md index bedc41b6b..e8159478d 100644 --- a/docs/rules/SubdivisionCode.md +++ b/docs/rules/SubdivisionCode.md @@ -9,8 +9,8 @@ The `$countryCode` must be a country in [ISO 3166-1 alpha-2][] format. **This rule requires [sokil/php-isocodes][] and [php-isocodes-db-only][] to be installed.** ```php -v::subdivisionCode('BR')->validate('SP'); // true -v::subdivisionCode('US')->validate('CA'); // true +v::subdivisionCode('BR')->isValid('SP'); // true +v::subdivisionCode('US')->isValid('CA'); // true ``` ## Categorization diff --git a/docs/rules/Subset.md b/docs/rules/Subset.md index 1fc1c9e07..cacba0bd9 100644 --- a/docs/rules/Subset.md +++ b/docs/rules/Subset.md @@ -5,8 +5,8 @@ Validates whether the input is a subset of a given value. ```php -v::subset([1, 2, 3])->validate([1, 2]); // true -v::subset([1, 2])->validate([1, 2, 3]); // false +v::subset([1, 2, 3])->isValid([1, 2]); // true +v::subset([1, 2])->isValid([1, 2, 3]); // false ``` ## Categorization diff --git a/docs/rules/SymbolicLink.md b/docs/rules/SymbolicLink.md index 175c4aaeb..d9c443876 100644 --- a/docs/rules/SymbolicLink.md +++ b/docs/rules/SymbolicLink.md @@ -5,9 +5,9 @@ Validates if the given input is a symbolic link. ```php -v::symbolicLink()->validate('/path/of/valid/symbolic/link'); // true -v::symbolicLink()->validate(new SplFileInfo('/path/of/valid/symbolic/link)); // true -v::symbolicLink()->validate(new SplFileObject('/path/of/valid/symbolic/link')); // true +v::symbolicLink()->isValid('/path/of/valid/symbolic/link'); // true +v::symbolicLink()->isValid(new SplFileInfo('/path/of/valid/symbolic/link)); // true +v::symbolicLink()->isValid(new SplFileObject('/path/of/valid/symbolic/link')); // true ``` ## Categorization diff --git a/docs/rules/Time.md b/docs/rules/Time.md index a5255447d..72d72ffff 100644 --- a/docs/rules/Time.md +++ b/docs/rules/Time.md @@ -23,15 +23,15 @@ Format | Description | Values When a `$format` is not given its default value is `H:i:s`. ```php -v::time()->validate('00:00:00'); // true -v::time()->validate('23:20:59'); // true -v::time('H:i')->validate('23:59'); // true -v::time('g:i A')->validate('8:13 AM'); // true -v::time('His')->validate(232059); // true - -v::time()->validate('24:00:00'); // false -v::time()->validate(new DateTime()); // false -v::time()->validate(new DateTimeImmutable()); // false +v::time()->isValid('00:00:00'); // true +v::time()->isValid('23:20:59'); // true +v::time('H:i')->isValid('23:59'); // true +v::time('g:i A')->isValid('8:13 AM'); // true +v::time('His')->isValid(232059); // true + +v::time()->isValid('24:00:00'); // false +v::time()->isValid(new DateTime()); // false +v::time()->isValid(new DateTimeImmutable()); // false ``` ## Categorization diff --git a/docs/rules/Tld.md b/docs/rules/Tld.md index b2859d2ab..731dc0746 100644 --- a/docs/rules/Tld.md +++ b/docs/rules/Tld.md @@ -5,10 +5,10 @@ Validates whether the input is a top-level domain. ```php -v::tld()->validate('com'); // true -v::tld()->validate('ly'); // true -v::tld()->validate('org'); // true -v::tld()->validate('COM'); // true +v::tld()->isValid('com'); // true +v::tld()->isValid('ly'); // true +v::tld()->isValid('org'); // true +v::tld()->isValid('COM'); // true ``` ## Categorization diff --git a/docs/rules/TrueVal.md b/docs/rules/TrueVal.md index a59c96f7c..94524a0d5 100644 --- a/docs/rules/TrueVal.md +++ b/docs/rules/TrueVal.md @@ -5,14 +5,14 @@ Validates if a value is considered as `true`. ```php -v::trueVal()->validate(true); // true -v::trueVal()->validate(1); // true -v::trueVal()->validate('1'); // true -v::trueVal()->validate('true'); // true -v::trueVal()->validate('on'); // true -v::trueVal()->validate('yes'); // true -v::trueVal()->validate('0.5'); // false -v::trueVal()->validate('2'); // false +v::trueVal()->isValid(true); // true +v::trueVal()->isValid(1); // true +v::trueVal()->isValid('1'); // true +v::trueVal()->isValid('true'); // true +v::trueVal()->isValid('on'); // true +v::trueVal()->isValid('yes'); // true +v::trueVal()->isValid('0.5'); // false +v::trueVal()->isValid('2'); // false ``` ## Categorization diff --git a/docs/rules/Type.md b/docs/rules/Type.md index f4275f8a2..e204883b9 100644 --- a/docs/rules/Type.md +++ b/docs/rules/Type.md @@ -5,9 +5,9 @@ Validates the type of input. ```php -v::type('bool')->validate(true); // true -v::type('callable')->validate(function (){}); // true -v::type('object')->validate(new stdClass()); // true +v::type('bool')->isValid(true); // true +v::type('callable')->isValid(function (){}); // true +v::type('object')->isValid(new stdClass()); // true ``` ## Categorization diff --git a/docs/rules/UndefOr.md b/docs/rules/UndefOr.md index 4ba70bd05..b9b05410c 100644 --- a/docs/rules/UndefOr.md +++ b/docs/rules/UndefOr.md @@ -7,11 +7,11 @@ Validates if the given input is undefined or not. By _undefined_ we consider `null` or an empty string (`''`), which implies that the input is not set. This is particularly useful when validating form fields ```php -v::undefOr(v::alpha())->validate(''); // true -v::undefOr(v::digit())->validate(null); // true +v::undefOr(v::alpha())->isValid(''); // true +v::undefOr(v::digit())->isValid(null); // true -v::undefOr(v::alpha())->validate('username'); // true -v::undefOr(v::alpha())->validate('has1number'); // false +v::undefOr(v::alpha())->isValid('username'); // true +v::undefOr(v::alpha())->isValid('has1number'); // false ``` ## Note @@ -19,8 +19,8 @@ v::undefOr(v::alpha())->validate('has1number'); // false For convenience, you can use the `undefOr` as a prefix to any rule: ```php -v::undefOrEmail()->validate('not an email'); // false -v::undefOrBetween(1, 3)->validate(2); // true +v::undefOrEmail()->isValid('not an email'); // false +v::undefOrBetween(1, 3)->isValid(2); // true ``` ## Categorization diff --git a/docs/rules/Unique.md b/docs/rules/Unique.md index 1d3d29fb3..683214533 100644 --- a/docs/rules/Unique.md +++ b/docs/rules/Unique.md @@ -5,10 +5,10 @@ Validates whether the input array contains only unique values. ```php -v::unique()->validate([]); // true -v::unique()->validate([1, 2, 3]); // true -v::unique()->validate([1, 2, 2, 3]); // false -v::unique()->validate([1, 2, 3, 1]); // false +v::unique()->isValid([]); // true +v::unique()->isValid([1, 2, 3]); // true +v::unique()->isValid([1, 2, 2, 3]); // false +v::unique()->isValid([1, 2, 3, 1]); // false ``` ## Categorization diff --git a/docs/rules/Uploaded.md b/docs/rules/Uploaded.md index 59766275e..27a5d0f47 100644 --- a/docs/rules/Uploaded.md +++ b/docs/rules/Uploaded.md @@ -5,7 +5,7 @@ Validates if the given data is a file that was uploaded via HTTP POST. ```php -v::uploaded()->validate('/path/of/an/uploaded/file'); // true +v::uploaded()->isValid('/path/of/an/uploaded/file'); // true ``` ## Categorization diff --git a/docs/rules/Uppercase.md b/docs/rules/Uppercase.md index 8f64ef06e..c9f5eab76 100644 --- a/docs/rules/Uppercase.md +++ b/docs/rules/Uppercase.md @@ -5,7 +5,7 @@ Validates whether the characters in the input are uppercase. ```php -v::uppercase()->validate('W3C'); // true +v::uppercase()->isValid('W3C'); // true ``` This rule does not validate if the input a numeric value, so `123` and `%` will @@ -13,9 +13,9 @@ be valid. Please add more validations to the chain if you want to refine your validation. ```php -v::not(v::numericVal())->uppercase()->validate('42'); // false -v::alnum()->uppercase()->validate('#$%!'); // false -v::not(v::numericVal())->alnum()->uppercase()->validate('W3C'); // true +v::not(v::numericVal())->uppercase()->isValid('42'); // false +v::alnum()->uppercase()->isValid('#$%!'); // false +v::not(v::numericVal())->alnum()->uppercase()->isValid('W3C'); // true ``` ## Categorization diff --git a/docs/rules/Url.md b/docs/rules/Url.md index 72bfd9758..d27c0b41d 100644 --- a/docs/rules/Url.md +++ b/docs/rules/Url.md @@ -5,11 +5,11 @@ Validates whether the input is a URL. ```php -v::url()->validate('http://example.com'); // true -v::url()->validate('https://www.youtube.com/watch?v=6FOUqQt3Kg0'); // true -v::url()->validate('ldap://[::1]'); // true -v::url()->validate('mailto:john.doe@example.com'); // true -v::url()->validate('news:new.example.com'); // true +v::url()->isValid('http://example.com'); // true +v::url()->isValid('https://www.youtube.com/watch?v=6FOUqQt3Kg0'); // true +v::url()->isValid('ldap://[::1]'); // true +v::url()->isValid('mailto:john.doe@example.com'); // true +v::url()->isValid('news:new.example.com'); // true ``` ## Categorization diff --git a/docs/rules/Uuid.md b/docs/rules/Uuid.md index 2a06ed6dc..b7d14bd3d 100644 --- a/docs/rules/Uuid.md +++ b/docs/rules/Uuid.md @@ -7,10 +7,10 @@ Validates whether the input is a valid UUID. It also supports validation of specific versions 1, 3, 4 and 5. ```php -v::uuid()->validate('Hello World!'); // false -v::uuid()->validate('eb3115e5-bd16-4939-ab12-2b95745a30f3'); // true -v::uuid(1)->validate('eb3115e5-bd16-4939-ab12-2b95745a30f3'); // false -v::uuid(4)->validate('eb3115e5-bd16-4939-ab12-2b95745a30f3'); // true +v::uuid()->isValid('Hello World!'); // false +v::uuid()->isValid('eb3115e5-bd16-4939-ab12-2b95745a30f3'); // true +v::uuid(1)->isValid('eb3115e5-bd16-4939-ab12-2b95745a30f3'); // false +v::uuid(4)->isValid('eb3115e5-bd16-4939-ab12-2b95745a30f3'); // true ``` ## Categorization diff --git a/docs/rules/Version.md b/docs/rules/Version.md index 6d2670929..db0c13a89 100644 --- a/docs/rules/Version.md +++ b/docs/rules/Version.md @@ -5,7 +5,7 @@ Validates version numbers using Semantic Versioning. ```php -v::version()->validate('1.0.0'); +v::version()->isValid('1.0.0'); ``` ## Categorization diff --git a/docs/rules/VideoUrl.md b/docs/rules/VideoUrl.md index b3a6cfbd9..22a15f813 100644 --- a/docs/rules/VideoUrl.md +++ b/docs/rules/VideoUrl.md @@ -6,23 +6,23 @@ Validates if the input is a video URL value. ```php -v::videoUrl()->validate('https://player.vimeo.com/video/71787467'); // true -v::videoUrl()->validate('https://vimeo.com/71787467'); // true -v::videoUrl()->validate('https://www.youtube.com/embed/netHLn9TScY'); // true -v::videoUrl()->validate('https://www.youtube.com/watch?v=netHLn9TScY'); // true -v::videoUrl()->validate('https://youtu.be/netHLn9TScY'); // true -v::videoUrl()->validate('https://www.twitch.tv/videos/320689092'); // true -v::videoUrl()->validate('https://clips.twitch.tv/BitterLazyMangetoutHumbleLife'); // true - -v::videoUrl('youtube')->validate('https://www.youtube.com/watch?v=netHLn9TScY'); // true -v::videoUrl('vimeo')->validate('https://vimeo.com/71787467'); // true -v::videoUrl('twitch')->validate('https://www.twitch.tv/videos/320689092'); // true -v::videoUrl('twitch')->validate('https://clips.twitch.tv/BitterLazyMangetoutHumbleLife'); // true - -v::videoUrl()->validate('https://youtube.com'); // false -v::videoUrl('youtube')->validate('https://vimeo.com/71787467'); // false -v::videoUrl('twitch')->validate('https://clips.twitch.tv/videos/90210'); // false -v::videoUrl('twitch')->validate('https://twitch.tv/TakeTeaAndNoTea'); // false +v::videoUrl()->isValid('https://player.vimeo.com/video/71787467'); // true +v::videoUrl()->isValid('https://vimeo.com/71787467'); // true +v::videoUrl()->isValid('https://www.youtube.com/embed/netHLn9TScY'); // true +v::videoUrl()->isValid('https://www.youtube.com/watch?v=netHLn9TScY'); // true +v::videoUrl()->isValid('https://youtu.be/netHLn9TScY'); // true +v::videoUrl()->isValid('https://www.twitch.tv/videos/320689092'); // true +v::videoUrl()->isValid('https://clips.twitch.tv/BitterLazyMangetoutHumbleLife'); // true + +v::videoUrl('youtube')->isValid('https://www.youtube.com/watch?v=netHLn9TScY'); // true +v::videoUrl('vimeo')->isValid('https://vimeo.com/71787467'); // true +v::videoUrl('twitch')->isValid('https://www.twitch.tv/videos/320689092'); // true +v::videoUrl('twitch')->isValid('https://clips.twitch.tv/BitterLazyMangetoutHumbleLife'); // true + +v::videoUrl()->isValid('https://youtube.com'); // false +v::videoUrl('youtube')->isValid('https://vimeo.com/71787467'); // false +v::videoUrl('twitch')->isValid('https://clips.twitch.tv/videos/90210'); // false +v::videoUrl('twitch')->isValid('https://twitch.tv/TakeTeaAndNoTea'); // false ``` The services accepted are: diff --git a/docs/rules/Vowel.md b/docs/rules/Vowel.md index 6d65179db..c91ba3bc0 100644 --- a/docs/rules/Vowel.md +++ b/docs/rules/Vowel.md @@ -6,7 +6,7 @@ Validates whether the input contains only vowels. ```php -v::vowel()->validate('aei'); // true +v::vowel()->isValid('aei'); // true ``` ## Categorization diff --git a/docs/rules/When.md b/docs/rules/When.md index eeee1f2cc..4cda058cc 100644 --- a/docs/rules/When.md +++ b/docs/rules/When.md @@ -9,11 +9,11 @@ When the `$if` validates, returns validation for `$then`. When the `$if` doesn't validate, returns validation for `$else`, if defined. ```php -v::when(v::intVal(), v::positive(), v::notEmpty())->validate(1); // true -v::when(v::intVal(), v::positive(), v::notEmpty())->validate('not empty'); // true +v::when(v::intVal(), v::positive(), v::notEmpty())->isValid(1); // true +v::when(v::intVal(), v::positive(), v::notEmpty())->isValid('not empty'); // true -v::when(v::intVal(), v::positive(), v::notEmpty())->validate(-1); // false -v::when(v::intVal(), v::positive(), v::notEmpty())->validate(''); // false +v::when(v::intVal(), v::positive(), v::notEmpty())->isValid(-1); // false +v::when(v::intVal(), v::positive(), v::notEmpty())->isValid(''); // false ``` In the sample above, if `$input` is an integer, then it must be positive. diff --git a/docs/rules/Writable.md b/docs/rules/Writable.md index 1e987c50c..f51d91930 100644 --- a/docs/rules/Writable.md +++ b/docs/rules/Writable.md @@ -5,7 +5,7 @@ Validates if the given input is writable file. ```php -v::writable()->validate('file.txt'); // true +v::writable()->isValid('file.txt'); // true ``` ## Categorization diff --git a/docs/rules/Xdigit.md b/docs/rules/Xdigit.md index ae4d926f1..e077a096d 100644 --- a/docs/rules/Xdigit.md +++ b/docs/rules/Xdigit.md @@ -6,13 +6,13 @@ Validates whether the input is an hexadecimal number or not. ```php -v::xdigit()->validate('abc123'); // true +v::xdigit()->isValid('abc123'); // true ``` Notice, however, that it doesn't accept strings starting with 0x: ```php -v::xdigit()->validate('0x1f'); // false +v::xdigit()->isValid('0x1f'); // false ``` ## Categorization diff --git a/docs/rules/Yes.md b/docs/rules/Yes.md index c46205cd3..79b601018 100644 --- a/docs/rules/Yes.md +++ b/docs/rules/Yes.md @@ -6,11 +6,11 @@ Validates if the input considered as "Yes". ```php -v::yes()->validate('Y'); // true -v::yes()->validate('Yea'); // true -v::yes()->validate('Yeah'); // true -v::yes()->validate('Yep'); // true -v::yes()->validate('Yes'); // true +v::yes()->isValid('Y'); // true +v::yes()->isValid('Yea'); // true +v::yes()->isValid('Yeah'); // true +v::yes()->isValid('Yep'); // true +v::yes()->isValid('Yes'); // true ``` This rule is case insensitive. @@ -20,13 +20,13 @@ constant, meaning that it will validate the input using your current location: ```php setlocale(LC_ALL, 'pt_BR'); -v::yes(true)->validate('Sim'); // true +v::yes(true)->isValid('Sim'); // true ``` Be careful when using `$locale` as `TRUE` because the it's very permissive: ```php -v::yes(true)->validate('Yydoesnotmatter'); // true +v::yes(true)->isValid('Yydoesnotmatter'); // true ``` Besides that, with `$locale` as `TRUE` it will consider any character starting @@ -34,7 +34,7 @@ with "Y" as valid: ```php setlocale(LC_ALL, 'ru_RU'); -v::yes(true)->validate('Yes'); // true +v::yes(true)->isValid('Yes'); // true ``` ## Categorization