├── LICENSE ├── README.md ├── composer.json └── src ├── AbstractRegexRule.php ├── AbstractRule.php ├── Exceptions └── NotExistingRuleException.php ├── Laravel └── ValidationServiceProvider.php ├── Rule.php ├── Rules ├── AustrianInsuranceNumber.php ├── Base64.php ├── Bic.php ├── Camelcase.php ├── Cidr.php ├── Creditcard.php ├── DataUri.php ├── Domainname.php ├── Ean.php ├── Grid.php ├── Gtin.php ├── Hexadecimalcolor.php ├── Hslcolor.php ├── Hsvcolor.php ├── Htmlclean.php ├── Iban.php ├── Imei.php ├── Isbn.php ├── Isin.php ├── Issn.php ├── Jwt.php ├── Kebabcase.php ├── LatLng.php ├── Latitude.php ├── Longitude.php ├── Lowercase.php ├── Luhn.php ├── MimeType.php ├── Postalcode.php ├── Semver.php ├── Slug.php ├── Snakecase.php ├── Titlecase.php ├── Ulid.php ├── Uppercase.php └── Username.php └── lang ├── ar └── validation.php ├── bn └── validation.php ├── de └── validation.php ├── en └── validation.php ├── es └── validation.php ├── fa └── validation.php ├── fi └── validation.php ├── fr └── validation.php ├── id └── validation.php ├── nl └── validation.php └── uk └── validation.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-present Oliver Vogel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intervention Validation 2 | 3 | Intervention Validation is an extension library for Laravel's own validation 4 | system. The package adds rules to validate data like IBAN, BIC, ISBN, 5 | creditcard numbers and more. 6 | 7 | [![Latest Version](https://img.shields.io/packagist/v/intervention/validation.svg)](https://packagist.org/packages/intervention/validation) 8 | [![Tests](https://github.com/Intervention/validation/actions/workflows/build.yml/badge.svg)](https://github.com/Intervention/validation/actions/workflows/build.yml) 9 | [![Monthly Downloads](https://img.shields.io/packagist/dm/intervention/validation.svg)](https://packagist.org/packages/intervention/validation/stats) 10 | [![Support me on Ko-fi](https://raw.githubusercontent.com/Intervention/validation/main/.github/images/support.svg)](https://ko-fi.com/interventionphp) 11 | 12 | ## Installation 13 | 14 | You can install this package quick and easy with Composer. 15 | 16 | Require the package via Composer: 17 | 18 | $ composer require intervention/validation 19 | 20 | ## Laravel integration 21 | 22 | The Validation library is built to work with the Laravel Framework (>=10). It 23 | comes with a service provider, which will be discovered automatically and 24 | registers the validation rules into your installation. The package provides 30 25 | additional validation rules including multi language error messages, which can 26 | be used like Laravel's own validation rules. 27 | 28 | ```php 29 | use Illuminate\Support\Facades\Validator; 30 | use Intervention\Validation\Rules\Creditcard; 31 | use Intervention\Validation\Rules\Hexadecimalcolor; 32 | use Intervention\Validation\Rules\Username; 33 | 34 | $validator = Validator::make($request->all(), [ 35 | 'color' => new Hexadecimalcolor([3, 6]), // pass rule as object 36 | 'number' => ['required', 'creditcard'], // or pass rule as string 37 | 'name' => 'required|min:3|max:20|username', // combining rules works as well 38 | ]); 39 | ``` 40 | 41 | ### Changing the error messages: 42 | 43 | Add the corresponding key to `/resources/lang//validation.php` like this: 44 | 45 | ```php 46 | // example 47 | 'iban' => 'Please enter IBAN number!', 48 | ``` 49 | Or add your custom messages directly to the validator like [described in the docs](https://laravel.com/docs/10.x/validation#manual-customizing-the-error-messages). 50 | 51 | ## Available Rules 52 | 53 | The following validation rules are available with this package. 54 | 55 | ### Austrian insurance Number (austrian social security number) 56 | 57 | The field under validation must be an [Austrian insurance number](https://de.wikipedia.org/wiki/Sozialversicherungsnummer#%C3%96sterreich) 58 | 59 | public Intervention\Validation\Rules\AustrianInsuranceNumber::__construct() 60 | 61 | ### Base64 encoded string 62 | 63 | The field under validation must be [Base64 encoded](https://en.wikipedia.org/wiki/Base64). 64 | 65 | public Intervention\Validation\Rules\Base64::__construct() 66 | 67 | ### Business Identifier Code (BIC) 68 | 69 | Checks for a valid [Business Identifier Code](https://en.wikipedia.org/wiki/ISO_9362) (BIC). 70 | 71 | public Intervention\Validation\Rules\Bic::__construct() 72 | 73 | ### Camel case string 74 | 75 | The field under validation must be a formatted in [Camel case](https://en.wikipedia.org/wiki/Camel_case). 76 | 77 | public Intervention\Validation\Rules\Camelcase::__construct() 78 | 79 | ### Classless Inter-Domain Routing (CIDR) 80 | 81 | Check if the value is a [Classless Inter-Domain Routing](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation (CIDR). 82 | 83 | public Intervention\Validation\Rules\Cidr::__construct() 84 | 85 | ### Creditcard Number 86 | 87 | The field under validation must be a valid [creditcard number](https://en.wikipedia.org/wiki/Payment_card_number). 88 | 89 | public Intervention\Validation\Rules\Creditcard::__construct() 90 | 91 | ### Data URI scheme 92 | 93 | The field under validation must be a valid [Data URI](https://en.wikipedia.org/wiki/Data_URI_scheme). 94 | 95 | public Intervention\Validation\Rules\DataUri::__construct(?array $media_types = null) 96 | 97 | ### Domain name 98 | 99 | The field under validation must be a well formed [domainname](https://en.wikipedia.org/wiki/Domain_name). 100 | 101 | public Intervention\Validation\Rules\Domainname::__construct() 102 | 103 | ### European Article Number (EAN) 104 | 105 | Checks for a valid [European Article Number](https://en.wikipedia.org/wiki/International_Article_Number). 106 | 107 | public Intervention\Validation\Rules\Ean::__construct(array $lengths = [8, 13]) 108 | 109 | #### Parameters 110 | 111 | **length** 112 | 113 | Optional integer length (8 or 13) to check only for EAN-8 or EAN-13. 114 | 115 | ### Global Release Identifier (GRid) 116 | 117 | The field under validation must be a [Global Release Identifier](https://en.wikipedia.org/wiki/Global_Release_Identifier). 118 | 119 | public Intervention\Validation\Rules\Grid::__construct() 120 | 121 | ### Global Trade Item Number (GTIN) 122 | 123 | Checks for a valid [Global Trade Item Number](https://en.wikipedia.org/wiki/Global_Trade_Item_Number). 124 | 125 | public Intervention\Validation\Rules\Gtin::__construct(array $lengths = [8, 12, 13, 14]) 126 | 127 | #### Parameters 128 | 129 | **length** 130 | 131 | Optional array of allowed lengths to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14). 132 | 133 | ### Hexadecimal color code 134 | 135 | The field under validation must be a valid [hexadecimal color code](https://en.wikipedia.org/wiki/Web_colors). 136 | 137 | public Intervention\Validation\Rules\Hexadecimalcolor::__construct(array $lengths = [3, 4, 6, 8]) 138 | 139 | #### Parameters 140 | 141 | **length** 142 | 143 | Optional length as integer to check only for shorthand (3 or 4 characters) or full hexadecimal (6 or 8 characters) form. 144 | 145 | ### HSL Color 146 | 147 | The field under validation must be a valid [HSL color code](https://en.wikipedia.org/wiki/HSL_and_HSV). 148 | 149 | public Intervention\Validation\Rules\Hslcolor::__construct() 150 | 151 | ### HSV Color 152 | 153 | The field under validation must be a valid [HSV/HSB color code](https://en.wikipedia.org/wiki/HSL_and_HSV). 154 | 155 | public Intervention\Validation\Rules\Hsvcolor::__construct() 156 | 157 | ### Text without HTML 158 | 159 | The field under validation must be free of any html code. 160 | 161 | public Intervention\Validation\Rules\HtmlClean::__construct() 162 | 163 | ### International Bank Account Number (IBAN) 164 | 165 | Checks for a valid [International Bank Account Number](https://en.wikipedia.org/wiki/International_Bank_Account_Number) (IBAN). 166 | 167 | public Intervention\Validation\Rules\Iban::__construct() 168 | 169 | ### International Mobile Equipment Identity (IMEI) 170 | 171 | The field under validation must be a [International Mobile Equipment Identity](https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity) (IMEI). 172 | 173 | public Intervention\Validation\Rules\Imei::__construct() 174 | 175 | ### International Standard Book Number (ISBN) 176 | 177 | The field under validation must be a valid [International Standard Book Number](https://en.wikipedia.org/wiki/International_Standard_Book_Number) (ISBN). 178 | 179 | public Intervention\Validation\Rules\Isbn::__construct(array $lengths = [10, 13]) 180 | 181 | #### Parameters 182 | 183 | **length** 184 | 185 | Optional length parameter as integer to check only for ISBN-10 or ISBN-13. 186 | 187 | ### International Securities Identification Number (ISIN) 188 | 189 | Checks for a valid [International Securities Identification Number](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (ISIN). 190 | 191 | public Intervention\Validation\Rules\Isin::__construct() 192 | 193 | ### International Standard Serial Number (ISSN) 194 | 195 | Checks for a valid [International Standard Serial Number](https://en.wikipedia.org/wiki/International_Standard_Serial_Number) (ISSN). 196 | 197 | public Intervention\Validation\Rules\Issn::__construct() 198 | 199 | ### JSON Web Token (JWT) 200 | 201 | The given value must be a in format of a [JSON Web Token](https://en.wikipedia.org/wiki/JSON_Web_Token). 202 | 203 | public Intervention\Validation\Rules\Jwt::__construct() 204 | 205 | ### Kebab case string 206 | 207 | The given value must be formatted in [Kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 208 | 209 | public Intervention\Validation\Rules\Kebabcase::__construct() 210 | 211 | ### Latitude 212 | 213 | Checks for a valid geographic [Latitude](https://en.wikipedia.org/wiki/Latitude). 214 | 215 | public Intervention\Validation\Rules\Latitude::__construct() 216 | 217 | ### Longitude 218 | 219 | Checks for a valid geographic [Longitude](https://en.wikipedia.org/wiki/Longitude). 220 | 221 | public Intervention\Validation\Rules\Longitude::__construct() 222 | 223 | ### LatLng 224 | 225 | Checks for a valid geographic comma separated pair of a [Latitude](https://en.wikipedia.org/wiki/Latitude) and a [Longitude](https://en.wikipedia.org/wiki/Longitude). 226 | 227 | public Intervention\Validation\Rules\LatLng::__construct() 228 | 229 | ### Lower case string 230 | 231 | The given value must be all lower case letters. 232 | 233 | public Intervention\Validation\Rules\Lowercase::__construct() 234 | 235 | ### Luhn algorithm 236 | 237 | The given value must verify against its included [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) check digit. 238 | 239 | public Intervention\Validation\Rules\Luhn::__construct() 240 | 241 | ### Media (MIME) type 242 | 243 | Checks for a valid [Mime Type](https://en.wikipedia.org/wiki/Media_type) (Media type). 244 | 245 | public Intervention\Validation\Rules\MimeType::__construct() 246 | 247 | ### Postal Code 248 | 249 | The field under validation must be a [postal code](https://en.wikipedia.org/wiki/Postal_code) of the given country. 250 | 251 | public Intervention\Validation\Rules\Postalcode::__construct(array $countrycodes = []) 252 | 253 | #### Parameters 254 | 255 | **countrycode** 256 | 257 | Country code in [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. 258 | 259 | ### Postal Code (static instantiation) 260 | 261 | public static Intervention\Validation\Rules\Postalcode::countrycode(array $countrycodes): Postalcode 262 | 263 | #### Parameters 264 | 265 | **countrycode** 266 | 267 | Country code in [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. 268 | 269 | ### Postal Code (static instantiation with reference) 270 | 271 | public static Intervention\Validation\Rules\Postalcode::reference(string $reference): Postalcode 272 | 273 | #### Parameters 274 | 275 | **reference** 276 | 277 | Reference key to get [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) country code from other data in validator. 278 | 279 | ### Semantic Version Number 280 | 281 | The field under validation must be a valid version numbers using [Semantic Versioning](https://semver.org/). 282 | 283 | public Intervention\Validation\Rules\SemVer::__construct() 284 | 285 | ### SEO-friendly short text (Slug) 286 | 287 | The field under validation must be a user- and [SEO-friendly short text](https://en.wikipedia.org/wiki/Clean_URL#Slug). 288 | 289 | public Intervention\Validation\Rules\Slug::__construct() 290 | 291 | ### Snake case string 292 | 293 | The field under validation must formatted as [Snake case](https://en.wikipedia.org/wiki/Snake_case) text. 294 | 295 | public Intervention\Validation\Rules\Snakecase::__construct() 296 | 297 | ### Title case string 298 | 299 | The field under validation must formatted in [Title case](https://en.wikipedia.org/wiki/Title_case). 300 | 301 | public Intervention\Validation\Rules\Titlecase::__construct() 302 | 303 | ### Universally Unique Lexicographically Sortable Identifier (ULID) 304 | 305 | The field under validation must be a valid [Universally Unique Lexicographically Sortable Identifier](https://github.com/ulid/spec). 306 | 307 | public Intervention\Validation\Rules\Ulid::__construct() 308 | 309 | ### Upper case string 310 | 311 | The field under validation must be all upper case. 312 | 313 | public Intervention\Validation\Rules\Uppercase::__construct() 314 | 315 | ### Username 316 | 317 | The field under validation must be a valid username. Consisting of 318 | alpha-numeric characters, underscores, minus and starting with a alphabetic 319 | character. Multiple underscore and minus chars are not allowed. Underscore and 320 | minus chars are not allowed at the beginning or end. 321 | 322 | public Intervention\Validation\Rules\Username::__construct() 323 | 324 | ## Development & Testing 325 | 326 | With this package comes a Docker image to build a test suite container. To 327 | build this container you have to have Docker installed on your system. You can 328 | run all tests with this command. 329 | 330 | $ docker-compose run --rm --build tests 331 | 332 | ## Authors 333 | 334 | This library is developed and maintained by [Oliver Vogel](https://intervention.io) 335 | 336 | Thanks to the community of [contributors](https://github.com/Intervention/validation/graphs/contributors) who have helped to improve this project. 337 | 338 | ## License 339 | 340 | Intervention Validation is licensed under the [MIT License](LICENSE). 341 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "intervention/validation", 3 | "description": "Additional validation rules for the Laravel framework", 4 | "homepage": "https://validation.intervention.io/", 5 | "keywords": [ 6 | "validation", 7 | "Validator", 8 | "laravel", 9 | "bic", 10 | "iban", 11 | "creditcard", 12 | "isbn", 13 | "ean", 14 | "gtin", 15 | "isin", 16 | "luhn", 17 | "base64", 18 | "data-url", 19 | "ulid" 20 | ], 21 | "license": "MIT", 22 | "authors": [ 23 | { 24 | "name": "Oliver Vogel", 25 | "email": "oliver@intervention.io", 26 | "homepage": "https://intervention.io/" 27 | } 28 | ], 29 | "require": { 30 | "php": "^8.1", 31 | "ext-mbstring": "*", 32 | "illuminate/validation": "^10 || ^11 || ^12" 33 | }, 34 | "require-dev": { 35 | "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", 36 | "phpstan/phpstan": "^2.1", 37 | "symfony/uid": "^5.1|^6.2", 38 | "slevomat/coding-standard": "~8.0", 39 | "squizlabs/php_codesniffer": "^3.8" 40 | }, 41 | "autoload": { 42 | "psr-4": { 43 | "Intervention\\Validation\\": "src" 44 | } 45 | }, 46 | "autoload-dev": { 47 | "psr-4": { 48 | "Intervention\\Validation\\Tests\\": "tests" 49 | } 50 | }, 51 | "extra": { 52 | "laravel": { 53 | "providers": [ 54 | "Intervention\\Validation\\Laravel\\ValidationServiceProvider" 55 | ] 56 | } 57 | }, 58 | "minimum-stability": "dev", 59 | "prefer-stable": true, 60 | "config": { 61 | "allow-plugins": { 62 | "dealerdirect/phpcodesniffer-composer-installer": true 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/AbstractRegexRule.php: -------------------------------------------------------------------------------- 1 | pattern(), (string) $value); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/AbstractRule.php: -------------------------------------------------------------------------------- 1 | isValid($value)) { 28 | $fail($this->message())->translate(); 29 | } 30 | } 31 | 32 | /** 33 | * Return shortname of current rule 34 | */ 35 | protected function shortname(): string 36 | { 37 | return strtolower((new ReflectionClass($this))->getShortName()); 38 | } 39 | 40 | /** 41 | * Return localized error message 42 | */ 43 | public function message(): string 44 | { 45 | // try key for application custom translation 46 | $key = 'validation.' . $this->shortname(); 47 | 48 | if (function_exists('trans')) { 49 | // if message is same as key, there is no 50 | // translation so we will use internal 51 | $message = trans($key); 52 | if ($message === $key) { 53 | return trans('validation::' . $key); 54 | } 55 | } 56 | 57 | return $key; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Exceptions/NotExistingRuleException.php: -------------------------------------------------------------------------------- 1 | loadTranslationsFrom( 20 | __DIR__ . '/../lang', 21 | 'validation' 22 | ); 23 | 24 | // add rules to laravel validator 25 | foreach ($this->ruleShortnames() as $rulename) { 26 | $this->app['validator']->extend( 27 | $rulename, 28 | function ($attribute, $value, $parameters, $validator) use ($rulename): bool { 29 | return $this->interventionRule($rulename, $parameters)->isValid($value); 30 | }, 31 | $this->errorMessage($rulename) 32 | ); 33 | } 34 | } 35 | 36 | /** 37 | * Return rule object for given shortname 38 | * 39 | * @param array $parameters 40 | * @throws NotExistingRuleException 41 | */ 42 | private function interventionRule(string $rulename, array $parameters): Rule 43 | { 44 | $classname = sprintf("Intervention\Validation\Rules\%s", ucfirst($rulename)); 45 | 46 | if (!class_exists($classname)) { 47 | throw new NotExistingRuleException("Rule " . $rulename . " does not exist."); 48 | } 49 | 50 | return new $classname($parameters); 51 | } 52 | 53 | /** 54 | * List all shortnames of Intervention validation rule objects 55 | * 56 | * @return array 57 | */ 58 | private function ruleShortnames(): array 59 | { 60 | return array_map( 61 | fn(string $filename): string => mb_strtolower(substr($filename, 0, -4)), 62 | array_diff(scandir(__DIR__ . '/../Rules'), ['.', '..']), 63 | ); 64 | } 65 | 66 | /** 67 | * Return error message of given rule shortname 68 | */ 69 | protected function errorMessage(string $rulename): string 70 | { 71 | return $this->app['translator']->get('validation::validation.' . $rulename); 72 | } 73 | 74 | /** 75 | * Return the services provided by the provider. 76 | * 77 | * @return array 78 | */ 79 | public function provides(): array 80 | { 81 | return ['validator']; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Rule.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | private array $multiplierSeries = [ 23 | 3, 7, 9, 5, 8, 4, 2, 1, 6 24 | ]; 25 | 26 | /** 27 | * {@inheritdoc} 28 | * 29 | * @see Rule::isValid() 30 | */ 31 | public function isValid(mixed $value): bool 32 | { 33 | $value = str_replace(' ', '', (string) $value); 34 | 35 | return is_numeric($value) 36 | && $this->startsNotWithZero($value) 37 | && $this->hasValidLength($value) 38 | && $this->hasValidBirthday($value) 39 | && $this->checkChecksum($value); 40 | } 41 | 42 | private function hasValidLength(string $svnumber): bool 43 | { 44 | return $this->length === strlen($svnumber); 45 | } 46 | 47 | private function startsNotWithZero(string $svnumber): bool 48 | { 49 | return (int) $svnumber[0] !== 0; 50 | } 51 | 52 | private function hasValidBirthday(string $svnumber): bool 53 | { 54 | $splittedBirthday = str_split(substr($svnumber, 4), 2); 55 | 56 | if (!in_array((int) $splittedBirthday[0], range(1, 31), true)) { 57 | return false; 58 | } 59 | 60 | if (!in_array((int) $splittedBirthday[1], range(1, 20), true)) { 61 | return false; 62 | } 63 | 64 | if (!in_array((int) $splittedBirthday[2], range(0, 99), true)) { 65 | return false; 66 | } 67 | 68 | return true; 69 | } 70 | 71 | private function checkChecksum(string $svnumber): bool 72 | { 73 | if (strlen($svnumber) !== $this->length) { 74 | return false; 75 | } 76 | 77 | $checksumSVNumber = (int) $svnumber[3]; 78 | $svnumberWithoutChecksum = substr($svnumber, 0, 3) . substr($svnumber, 4); 79 | 80 | $sum = 0; 81 | for ($c = 0, $cMax = strlen($svnumberWithoutChecksum); $c < $cMax; $c++) { 82 | $result = (int) $svnumberWithoutChecksum[$c] * $this->multiplierSeries[$c]; 83 | $sum += $result; 84 | } 85 | $checksum = $sum % 11; 86 | 87 | if ($checksum === 10) { 88 | return false; 89 | } 90 | return $checksum === $checksumSVNumber; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Rules/Base64.php: -------------------------------------------------------------------------------- 1 | 32) { 40 | return false; 41 | } 42 | 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Rules/Creditcard.php: -------------------------------------------------------------------------------- 1 | hasValidLength($value) && parent::isValid($value); 17 | } 18 | 19 | /** 20 | * Check if the given value has the proper length for creditcards 21 | */ 22 | private function hasValidLength(mixed $value): bool 23 | { 24 | return (strlen(strval($value)) >= 13 && strlen(strval($value)) <= 19); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Rules/DataUri.php: -------------------------------------------------------------------------------- 1 | $media_types 15 | * @return void 16 | */ 17 | public function __construct(private ?array $media_types = null) 18 | { 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | * 24 | * @see Rule::isValid() 25 | */ 26 | public function isValid(mixed $value): bool 27 | { 28 | $info = $this->dataUriInfo($value); 29 | 30 | if (!$info->isValid()) { 31 | return false; 32 | } 33 | 34 | if ($info->hasMediaType() && !$this->isValidMimeType($info->mediaType())) { 35 | return false; 36 | } 37 | 38 | if ($this->expectsMediaType() && !$info->hasMediaType()) { 39 | return false; 40 | } 41 | 42 | if ($this->expectsMediaType() && !$this->isAllowedMimeType($info->mediaType())) { 43 | return false; 44 | } 45 | 46 | if ($info->isBase64Encoded()) { 47 | return $this->isValidBase64EncodedValue($info->data()); 48 | } 49 | 50 | return true; 51 | } 52 | 53 | /** 54 | * Determine if the rule expects a set mime type in the data url 55 | */ 56 | private function expectsMediaType(): bool 57 | { 58 | return is_array($this->media_types); 59 | } 60 | 61 | /** 62 | * Check for validity of given mime type 63 | */ 64 | private function isValidMimeType(mixed $value): bool 65 | { 66 | return (new MimeType())->isValid($value); 67 | } 68 | 69 | /** 70 | * Check if give mime type is allowed 71 | */ 72 | private function isAllowedMimeType(mixed $type): bool 73 | { 74 | if (is_null($this->media_types)) { 75 | return true; 76 | } 77 | 78 | if ($this->media_types === []) { 79 | return false; 80 | } 81 | 82 | return in_array($type, $this->media_types, true); 83 | } 84 | 85 | private function isValidBase64EncodedValue(mixed $value): bool 86 | { 87 | return (new Base64())->isValid($value); 88 | } 89 | 90 | /** 91 | * Parse data url info from current value 92 | */ 93 | private function dataUriInfo(mixed $value): object 94 | { 95 | $pattern = "/^data:(?P\w+\/[-+.\w]+)?(?P" . 96 | "(;[-\w]+=[-\w]+)*)(?P;base64)?,(?P.*)/"; 97 | $result = preg_match($pattern, strval($value), $matches); 98 | 99 | return new class ($matches, $result) 100 | { 101 | /** 102 | * @param array $matches 103 | * @return void 104 | */ 105 | public function __construct(private array $matches, private int|false $result) 106 | { 107 | // 108 | } 109 | 110 | public function isValid(): bool 111 | { 112 | return (bool) $this->result; 113 | } 114 | 115 | public function mediaType(): ?string 116 | { 117 | if (isset($this->matches['mediatype']) && !empty($this->matches['mediatype'])) { 118 | return $this->matches['mediatype']; 119 | } 120 | 121 | return null; 122 | } 123 | 124 | public function hasMediaType(): bool 125 | { 126 | return !empty($this->mediaType()); 127 | } 128 | 129 | /** @return array */ 130 | public function parameters(): array 131 | { 132 | if (isset($this->matches['parameters']) && !empty($this->matches['parameters'])) { 133 | return explode(';', trim((string) $this->matches['parameters'], ';')); 134 | } 135 | 136 | return []; 137 | } 138 | 139 | public function isBase64Encoded(): bool 140 | { 141 | return isset($this->matches['base64']) && $this->matches['base64'] === ';base64'; 142 | } 143 | 144 | public function data(): ?string 145 | { 146 | if (isset($this->matches['data']) && !empty($this->matches['data'])) { 147 | return $this->matches['data']; 148 | } 149 | 150 | return null; 151 | } 152 | }; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/Rules/Domainname.php: -------------------------------------------------------------------------------- 1 | labels($value); // get labels of domainname 19 | $tld = end($labels); // most right label of domainname is tld 20 | 21 | // domain must have 2 labels minimum 22 | if (count($labels) <= 1) { 23 | return false; 24 | } 25 | 26 | // each label must be valid 27 | foreach ($labels as $label) { 28 | if (!$this->isValidLabel($label)) { 29 | return false; 30 | } 31 | } 32 | 33 | return $this->isValidTld($tld); 34 | } 35 | 36 | /** 37 | * Get all labels of domainname 38 | * 39 | * @return array 40 | */ 41 | private function labels(mixed $value): array 42 | { 43 | return explode('.', $this->idnToAscii($value)); 44 | } 45 | 46 | /** 47 | * Determine if given string is valid idn label 48 | */ 49 | private function isValidLabel(string $value): bool 50 | { 51 | return $this->isValidALabel($value) || $this->isValidNrLdhLabel($value); 52 | } 53 | 54 | /** 55 | * Determine if given value is valid A-Label 56 | * 57 | * Begins with "xn--" and is resolvable by PunyCode algorithm 58 | */ 59 | private function isValidALabel(string $value): bool 60 | { 61 | return str_starts_with($value, 'xn--') && $this->idnToUtf8($value) != false; 62 | } 63 | 64 | /** 65 | * Determine if given value is valid NR-LDH label 66 | */ 67 | private function isValidNrLdhLabel(string $value): bool 68 | { 69 | return (bool) preg_match("/^(?!\-)[a-z0-9\-]{1,63}(?isValidALabel($value)) { 78 | return true; 79 | } 80 | 81 | return (bool) preg_match("/^[a-z]{2,63}$/i", $value); 82 | } 83 | 84 | /** 85 | * Wrapper method for idn_to_utf8 call 86 | */ 87 | private function idnToUtf8(string $domain): string 88 | { 89 | return idn_to_utf8($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46); 90 | } 91 | 92 | /** 93 | * Wrapper method for idn_to_ascii call 94 | */ 95 | private function idnToAscii(string $domain): string 96 | { 97 | $domain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46); 98 | 99 | return $domain ?: ''; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Rules/Ean.php: -------------------------------------------------------------------------------- 1 | $lengths 15 | * @return void 16 | */ 17 | public function __construct(private array $lengths = [8, 13]) 18 | { 19 | // 20 | } 21 | 22 | /** 23 | * {@inheritdoc} 24 | * 25 | * @see Rule::isValid() 26 | */ 27 | public function isValid(mixed $value): bool 28 | { 29 | return is_numeric($value) && $this->hasAllowedLength($value) && $this->checksumMatches($value); 30 | } 31 | 32 | /** 33 | * Determine if the current value has the lengths of EAN-8 or EAN-13 34 | */ 35 | protected function hasAllowedLength(mixed $value): bool 36 | { 37 | return in_array(strlen(strval($value)), $this->lengths); 38 | } 39 | 40 | /** 41 | * Try to calculate the EAN checksum of the 42 | * current value and check the matching. 43 | */ 44 | protected function checksumMatches(mixed $value): bool 45 | { 46 | return $this->calculateChecksum($value) === $this->cutChecksum($value); 47 | } 48 | 49 | /** 50 | * Cut out the checksum of the current value and return 51 | */ 52 | private function cutChecksum(mixed $value): int 53 | { 54 | return intval(substr(strval($value), -1)); 55 | } 56 | 57 | /** 58 | * Calculate modulo checksum of given value 59 | */ 60 | private function calculateChecksum(mixed $value): int 61 | { 62 | $checksum = 0; 63 | 64 | // chars without check digit in reverse 65 | $chars = array_reverse(str_split(substr(strval($value), 0, -1))); 66 | 67 | foreach ($chars as $key => $char) { 68 | $multiplier = $key % 2 ? 1 : 3; 69 | $checksum += intval($char) * $multiplier; 70 | } 71 | 72 | $remainder = $checksum % 10; 73 | 74 | if ($remainder === 0) { 75 | return 0; 76 | } 77 | 78 | return 10 - $remainder; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Rules/Grid.php: -------------------------------------------------------------------------------- 1 | A1-?[A-Z0-9]{5}-?[A-Z0-9]{10}-?[A-Z0-9])$/"; 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | * 24 | * @see Rule::isValid() 25 | */ 26 | public function isValid(mixed $value): bool 27 | { 28 | return is_string($value) 29 | && parent::isValid(strtoupper($value)) 30 | && $this->hasValidChecksum($value); 31 | } 32 | 33 | /** 34 | * Calculate checksum from given grid number 35 | */ 36 | private function hasValidChecksum(string $value): bool 37 | { 38 | // get GRid from value 39 | preg_match($this->pattern(), strtoupper($value), $matches); 40 | 41 | // split GRid into single characters (without dashes) 42 | $characters = str_split( 43 | str_replace('-', '', $matches['grid']) 44 | ); 45 | 46 | // extract last (check) character 47 | $checkCharacter = array_pop($characters); 48 | 49 | $m = 36; 50 | $n = 37; 51 | $product = $m; 52 | $sum = 0; 53 | 54 | // calculate checksum 55 | foreach ($characters as $char) { 56 | $sum = ($product + $this->charValue($char)) % $m; 57 | $sum = $sum === 0 ? $m : $sum; 58 | $product = ($sum * 2) % $n; 59 | } 60 | 61 | // compare checksum to check character value 62 | return $n - $product === $this->charValue($checkCharacter); 63 | } 64 | 65 | /** 66 | * Get character value according to GRid standard v2.1 67 | */ 68 | private function charValue(string $char): int 69 | { 70 | if (is_numeric($char)) { 71 | return (int) $char; 72 | } 73 | 74 | return (int) str_replace( 75 | range('A', 'Z'), 76 | array_map(fn(int $val): string => strval($val), range(10, 35)), 77 | strtoupper($char), 78 | ); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Rules/Gtin.php: -------------------------------------------------------------------------------- 1 | $lengths 20 | * @return void 21 | */ 22 | public function __construct(private array $lengths = [8, 12, 13, 14]) 23 | { 24 | parent::__construct($this->lengths); 25 | } 26 | 27 | /** 28 | * {@inheritdoc} 29 | * 30 | * @see Rule::isValid() 31 | */ 32 | public function isValid(mixed $value): bool 33 | { 34 | if (!is_numeric($value)) { 35 | return false; 36 | } 37 | 38 | if (!$this->hasAllowedLength($value)) { 39 | return false; 40 | } 41 | 42 | return match (strlen($value)) { 43 | 8, 13 => parent::isValid($value), 44 | 12 => parent::checksumMatches('0' . $value), 45 | 14 => parent::checksumMatches(substr($value, 1)), 46 | default => false, 47 | }; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Rules/Hexadecimalcolor.php: -------------------------------------------------------------------------------- 1 | $lengths 15 | * @return void 16 | */ 17 | public function __construct(protected array $lengths = [3, 4, 6, 8]) 18 | { 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | * 24 | * @see AbstractRegexRule::pattern() 25 | */ 26 | protected function pattern(): string 27 | { 28 | return '/^#?(?P[a-f\d]{3}(?:[a-f\d]?|(?:[a-f\d]{3}(?:[a-f\d]{2})?)?)\b)$/i'; 29 | } 30 | 31 | /** 32 | * {@inheritdoc} 33 | * 34 | * @see Rule::isValid() 35 | */ 36 | public function isValid(mixed $value): bool 37 | { 38 | if (!$this->hasAllowedLength($value)) { 39 | return false; 40 | } 41 | 42 | return parent::isValid($value); 43 | } 44 | 45 | /** 46 | * Determine if the current value has correct length 47 | */ 48 | private function hasAllowedLength(mixed $value): bool 49 | { 50 | return in_array(strlen(trim(strval($value), '#')), $this->lengths); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Rules/Hslcolor.php: -------------------------------------------------------------------------------- 1 | [0-9\.]+), ?(?P[0-9\.]+%?), ?(?P[0-9\.]+%?)?\)$/i'; 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | * 24 | * @see Rule::isValid() 25 | */ 26 | public function isValid(mixed $value): bool 27 | { 28 | $result = preg_match($this->pattern(), strval($value), $matches); 29 | 30 | if ($result !== 1) { 31 | return false; 32 | } 33 | 34 | if (!in_array(intval($matches['h']), range(0, 360))) { 35 | return false; 36 | } 37 | 38 | if (!in_array(intval($matches['s']), range(0, 100))) { 39 | return false; 40 | } 41 | 42 | if (!in_array(intval($matches['l']), range(0, 100))) { 43 | return false; 44 | } 45 | 46 | return true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Rules/Hsvcolor.php: -------------------------------------------------------------------------------- 1 | [0-9\.]+), ?(?P[0-9\.]+%?), ?(?P[0-9\.]+%?)?\)$/i'; 19 | } 20 | 21 | /** 22 | * {@inheritdoc} 23 | * 24 | * @see Rule::isValid() 25 | */ 26 | public function isValid(mixed $value): bool 27 | { 28 | $result = preg_match($this->pattern(), strval($value), $matches); 29 | 30 | if ($result !== 1) { 31 | return false; 32 | } 33 | 34 | if (!in_array(intval($matches['h']), range(0, 360))) { 35 | return false; 36 | } 37 | 38 | if (!in_array(intval($matches['s']), range(0, 100))) { 39 | return false; 40 | } 41 | 42 | if (!in_array(intval($matches['v']), range(0, 100))) { 43 | return false; 44 | } 45 | 46 | return true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Rules/Htmlclean.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | private array $lengths = [ 17 | 'AL' => 28, 18 | 'AD' => 24, 19 | 'AT' => 20, 20 | 'AZ' => 28, 21 | 'BH' => 22, 22 | 'BY' => 28, 23 | 'BE' => 16, 24 | 'BA' => 20, 25 | 'BR' => 29, 26 | 'BG' => 22, 27 | 'CR' => 22, 28 | 'HR' => 21, 29 | 'CY' => 28, 30 | 'CZ' => 24, 31 | 'DK' => 18, 32 | 'DO' => 28, 33 | 'EG' => 29, 34 | 'SV' => 28, 35 | 'EE' => 20, 36 | 'FO' => 18, 37 | 'FI' => 18, 38 | 'FR' => 27, 39 | 'GE' => 22, 40 | 'DE' => 22, 41 | 'GI' => 23, 42 | 'GR' => 27, 43 | 'GL' => 18, 44 | 'GT' => 28, 45 | 'VA' => 22, 46 | 'HU' => 28, 47 | 'IS' => 26, 48 | 'IQ' => 23, 49 | 'IE' => 22, 50 | 'IL' => 23, 51 | 'IT' => 27, 52 | 'JO' => 30, 53 | 'KZ' => 20, 54 | 'XK' => 20, 55 | 'KW' => 30, 56 | 'LV' => 21, 57 | 'LB' => 28, 58 | 'LI' => 21, 59 | 'LT' => 20, 60 | 'LU' => 20, 61 | 'MT' => 31, 62 | 'MR' => 27, 63 | 'MU' => 30, 64 | 'MD' => 24, 65 | 'MC' => 27, 66 | 'ME' => 22, 67 | 'NL' => 18, 68 | 'MK' => 19, 69 | 'NO' => 15, 70 | 'PK' => 24, 71 | 'PS' => 29, 72 | 'PL' => 28, 73 | 'PT' => 25, 74 | 'QA' => 29, 75 | 'RO' => 24, 76 | 'LC' => 32, 77 | 'SM' => 27, 78 | 'ST' => 25, 79 | 'SA' => 24, 80 | 'RS' => 22, 81 | 'SC' => 31, 82 | 'SK' => 24, 83 | 'SI' => 19, 84 | 'ES' => 24, 85 | 'SE' => 24, 86 | 'CH' => 21, 87 | 'TL' => 23, 88 | 'TN' => 24, 89 | 'TR' => 26, 90 | 'UA' => 29, 91 | 'AE' => 23, 92 | 'GB' => 22, 93 | 'VG' => 24, 94 | 95 | // partial iban countries (experimental) 96 | 'DZ' => 26, 97 | 'AO' => 25, 98 | 'BJ' => 28, 99 | 'BF' => 28, 100 | 'BI' => 16, 101 | 'CM' => 27, 102 | 'CV' => 25, 103 | 'CF' => 27, 104 | 'TD' => 27, 105 | 'KM' => 27, 106 | 'CG' => 27, 107 | 'DJ' => 27, 108 | 'GQ' => 27, 109 | 'GA' => 27, 110 | 'GW' => 25, 111 | 'HN' => 28, 112 | 'IR' => 26, 113 | 'CI' => 28, 114 | 'MG' => 27, 115 | 'ML' => 28, 116 | 'MA' => 28, 117 | 'MZ' => 25, 118 | 'NI' => 32, 119 | 'NE' => 28, 120 | 'SN' => 28, 121 | 'TG' => 28, 122 | ]; 123 | 124 | /** 125 | * {@inheritdoc} 126 | * 127 | * @see Rule::isValid() 128 | */ 129 | public function isValid(mixed $value): bool 130 | { 131 | // normalize value 132 | $value = str_replace(' ', '', strtoupper(strval($value))); 133 | 134 | // check iban length and checksum 135 | return $this->hasValidLength($value) && $this->checksum($value) === 1; 136 | } 137 | 138 | /** 139 | * Calculate checksum of iban 140 | */ 141 | private function checksum(string $iban): int 142 | { 143 | $iban = substr($iban, 4) . substr($iban, 0, 4); 144 | $iban = str_replace( 145 | $this->replacementsChars(), 146 | $this->replacementsValues(), 147 | $iban 148 | ); 149 | 150 | $checksum = intval(substr($iban, 0, 1)); 151 | 152 | for ($strcounter = 1; $strcounter < strlen($iban); $strcounter++) { 153 | $checksum *= 10; 154 | $checksum += intval(substr($iban, $strcounter, 1)); 155 | $checksum %= 97; 156 | } 157 | 158 | return $checksum; // only 1 is iban 159 | } 160 | 161 | /** 162 | * Returns the designated length of IBAN for given IBAN 163 | */ 164 | private function designatedIbanLength(string $iban): int|false 165 | { 166 | $countrycode = substr($iban, 0, 2); 167 | 168 | return $this->lengths[$countrycode] ?? false; 169 | } 170 | 171 | /** 172 | * Determine if given iban has the proper length 173 | */ 174 | private function hasValidLength(string $iban): bool 175 | { 176 | return $this->designatedIbanLength($iban) == strlen($iban); 177 | } 178 | 179 | /** 180 | * Get chars to be replaced in checksum calculation 181 | * 182 | * @return array 183 | */ 184 | private function replacementsChars(): array 185 | { 186 | return range('A', 'Z'); 187 | } 188 | 189 | /** 190 | * Get values to replace chars in checksum calculation 191 | * 192 | * @return array 193 | */ 194 | private function replacementsValues(): array 195 | { 196 | $values = []; 197 | foreach (range(10, 35) as $value) { 198 | $values[] = strval($value); 199 | } 200 | 201 | return $values; 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /src/Rules/Imei.php: -------------------------------------------------------------------------------- 1 | hasValidLength($value) && parent::isValid($value); 17 | } 18 | 19 | /** 20 | * Determine if current value has valid IMEI length 21 | */ 22 | private function hasValidLength(string $value): bool 23 | { 24 | return strlen($value) === 15; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Rules/Isbn.php: -------------------------------------------------------------------------------- 1 | $lengths 11 | * @return void 12 | */ 13 | public function __construct(private array $lengths = [10, 13]) 14 | { 15 | parent::__construct($this->lengths); 16 | } 17 | 18 | /** 19 | * {@inheritdoc} 20 | * 21 | * @see Rule::isValid() 22 | */ 23 | public function isValid(mixed $value): bool 24 | { 25 | // normalize value 26 | $value = preg_replace("/[^0-9x]/i", '', (string) $value); 27 | 28 | if (!$this->hasAllowedLength($value)) { 29 | return false; 30 | } 31 | 32 | return match (strlen((string) $value)) { 33 | 10 => $this->shortChecksumMatches($value), 34 | 13 => preg_match("/^(978|979)/", (string) $value) && parent::checksumMatches($value), 35 | default => false, 36 | }; 37 | } 38 | 39 | /** 40 | * Determine if checksum for ISBN-10 numbers is valid 41 | */ 42 | private function shortChecksumMatches(string $value): bool 43 | { 44 | return $this->shortChecksum($value) % 11 === 0; 45 | } 46 | 47 | /** 48 | * Calculate checksum of short ISBN numbers 49 | */ 50 | private function shortChecksum(string $value): int 51 | { 52 | $checksum = 0; 53 | $multiplier = 10; 54 | foreach (str_split($value) as $digit) { 55 | $digit = strtolower($digit) === 'x' ? 10 : intval($digit); 56 | $checksum += $digit * $multiplier; 57 | $multiplier--; 58 | } 59 | 60 | return $checksum; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Rules/Isin.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | private array $chars = [ 15 | 10 => 'A', 16 | 11 => 'B', 17 | 12 => 'C', 18 | 13 => 'D', 19 | 14 => 'E', 20 | 15 => 'F', 21 | 16 => 'G', 22 | 17 => 'H', 23 | 18 => 'I', 24 | 19 => 'J', 25 | 20 => 'K', 26 | 21 => 'L', 27 | 22 => 'M', 28 | 23 => 'N', 29 | 24 => 'O', 30 | 25 => 'P', 31 | 26 => 'Q', 32 | 27 => 'R', 33 | 28 => 'S', 34 | 29 => 'T', 35 | 30 => 'U', 36 | 31 => 'V', 37 | 32 => 'W', 38 | 33 => 'X', 39 | 34 => 'Y', 40 | 35 => 'Z', 41 | ]; 42 | 43 | /** 44 | * {@inheritdoc} 45 | * 46 | * @see Rule::isValid() 47 | */ 48 | public function isValid(mixed $value): bool 49 | { 50 | return parent::isValid($this->normalize($value)); 51 | } 52 | 53 | /** 54 | * Get value to check against 55 | */ 56 | public function normalize(string $value): string 57 | { 58 | return $this->replaceChars($this->valueWithoutLastDigit($value)) . $this->lastDigit($value); 59 | } 60 | 61 | /** 62 | * Replace chars in given value with corresponding numbers 63 | */ 64 | private function replaceChars(string $value): string 65 | { 66 | return str_replace( 67 | $this->chars, 68 | array_map(fn(int $value): string => strval($value), array_keys($this->chars)), 69 | $value, 70 | ); 71 | } 72 | 73 | /** 74 | * Return value without last digit 75 | */ 76 | private function valueWithoutLastDigit(string $value): string 77 | { 78 | return substr($value, 0, -1); 79 | } 80 | 81 | /** 82 | * Return last digit of current value 83 | */ 84 | private function lastDigit(string $value): string 85 | { 86 | return substr($value, -1); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Rules/Issn.php: -------------------------------------------------------------------------------- 1 | checkSumMatches($value); 29 | } 30 | 31 | /** 32 | * Determine if checksum matches 33 | */ 34 | private function checkSumMatches(string $value): bool 35 | { 36 | return $this->calculateChecksum($value) === $this->parseChecksum($value); 37 | } 38 | 39 | /** 40 | * Calculate checksum from the current value 41 | */ 42 | private function calculateChecksum(string $value): int 43 | { 44 | $checksum = 0; 45 | $issn_numbers = str_replace('-', '', $value); 46 | 47 | foreach (range(8, 2) as $num => $multiplicator) { 48 | $checksum += intval($issn_numbers[$num]) * $multiplicator; 49 | } 50 | 51 | $remainder = ($checksum % 11); 52 | 53 | return $remainder === 0 ? 0 : 11 - $remainder; 54 | } 55 | 56 | /** 57 | * Parse attached checksum of current value (last digit) 58 | */ 59 | private function parseChecksum(string $value): int 60 | { 61 | $last = substr($value, -1); 62 | 63 | return strtolower($last) === 'x' ? 10 : intval($last); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Rules/Jwt.php: -------------------------------------------------------------------------------- 1 | pattern(), 2, -2); 19 | $lng = substr((new Longitude())->pattern(), 2, -2); 20 | 21 | return "/^" . $lat . ", ?" . $lng . "$/"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Rules/Latitude.php: -------------------------------------------------------------------------------- 1 | checksumIsValid($this->checksum($value)); 19 | } 20 | 21 | /** 22 | * Determine if the given checksum is valid 23 | */ 24 | private function checksumIsValid(int $checksum): bool 25 | { 26 | return $checksum % 10 === 0; 27 | } 28 | 29 | /** 30 | * Calculate checksum for the given value 31 | */ 32 | private function checksum(mixed $value): int 33 | { 34 | $checksum = 0; 35 | $reverse = strrev(strval($value)); 36 | 37 | foreach (str_split($reverse) as $num => $digit) { 38 | if (is_numeric($digit)) { 39 | $checksum += $num & 1 ? ($digit > 4 ? (int) $digit * 2 - 9 : (int) $digit * 2) : $digit; 40 | } else { 41 | return -1; 42 | } 43 | } 44 | 45 | return (int) $checksum; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Rules/MimeType.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | private array $data = []; 23 | 24 | /** 25 | * Create a new rule instance with allowed countrycodes 26 | * 27 | * @param array $countrycodes 28 | */ 29 | public function __construct(protected array $countrycodes = []) 30 | { 31 | // 32 | } 33 | 34 | /** 35 | * Static constructor method to create data aware validation rule which 36 | * reads the allowed country code by reference. 37 | */ 38 | public static function reference(string $reference): self 39 | { 40 | $rule = new self(); 41 | $rule->reference = $reference; 42 | 43 | return $rule; 44 | } 45 | 46 | /** 47 | * Static constructor method 48 | * 49 | * @param array $countrycodes 50 | */ 51 | public static function countrycode(array $countrycodes): self 52 | { 53 | return new self($countrycodes); 54 | } 55 | 56 | /** 57 | * Set data 58 | * 59 | * @param array $data 60 | */ 61 | public function setData(array $data): static 62 | { 63 | $this->data = $data; 64 | 65 | return $this; 66 | } 67 | 68 | /** 69 | * {@inheritdoc} 70 | * 71 | * @see Rule::isValid() 72 | */ 73 | public function isValid(mixed $value): bool 74 | { 75 | foreach ($this->patterns() as $pattern) { 76 | if (preg_match($pattern, (string) $value)) { 77 | return true; 78 | } 79 | } 80 | 81 | return false; 82 | } 83 | 84 | /** 85 | * Return regex patterns for allowed country codes 86 | * 87 | * @return array 88 | */ 89 | private function patterns(): array 90 | { 91 | $patterns = array_map(fn(string $countrycode): ?string => $this->pattern($countrycode), $this->countryCodes()); 92 | 93 | return array_filter($patterns, fn(?string $pattern): bool => !is_null($pattern)); 94 | } 95 | 96 | /** 97 | * Get array of allowed country codes 98 | * 99 | * @return array 100 | */ 101 | private function countryCodes(): array 102 | { 103 | if (count($this->countrycodes) != 0) { 104 | return $this->countrycodes; 105 | } 106 | 107 | // return country code by reference 108 | if (!is_null($this->reference) && array_key_exists($this->reference, $this->data)) { 109 | return [$this->data[$this->reference]]; 110 | } 111 | 112 | return $this->countrycodes; 113 | } 114 | 115 | /** 116 | * Return regex pattern for postal code of current country code 117 | */ 118 | private function pattern(string $countrycode): ?string 119 | { 120 | return match (strtolower($countrycode)) { 121 | 'dz', 'as', 'ad', 'de', 'ba', 'ic', 'mp', 'hr', 'cu', 'ee', 'fi', 'fr', 'gf', 'gp', 'gu', 'id', 'it', 'kr', 122 | 'kv', 'lt', 'my', 'mh', 'mq', 'yt', 'fm', 'mc', 'me', 'ma', 'nc', 'pk', 'pw', 'pr', 're', 'sm', 'rs', 123 | 'es', 'xy', 'th', 'tr', 'ua', 'us', 'vi' => "/^[0-9]{5}$/", 124 | 'fo', 'is', 'mg', 'pg' => "/^[0-9]{3}$/", 125 | 'cz', 'gr', 'sk', 'se' => "/^[0-9]{3} [0-9]{2}$/", 126 | 'il' => "/^[0-9]{5}([0-9]{2})?$/", 127 | 'br' => "/^[0-9]{5}(-?[0-9]{3})?$/", 128 | 'gg', 'je' => "/^[a-z]{2}[0-9][0-9]? [0-9][a-z]{2}$/i", 129 | 'bn' => "/^[a-z]{2}[0-9]{4}$/i", 130 | 'jp' => "/^[0-9]{3}-[0-9]{4}$/", 131 | 'nl' => "/^[0-9]{4}\s?[a-z]{2}$/i", 132 | 'ar', 'am', 'au', 'at', 'bd', 'be', 'bg', 'cy', 'dk', 'ge', 'gl', 'hu', 'lv', 'li', 'lu', 'mk', 'md', 'nz', 133 | 'no', 'ph', 'si', 'za', 'ch', 'tn' => "/^[0-9]{4}$/", 134 | 'mv', 'mx' => "/^[0-9]{4}[0-9]?$/", 135 | 'mn' => "/^[0-9]{5}[0-9]?$/", 136 | 'pl' => "/^[0-9]{2}-[0-9]{3}$/", 137 | 'pt' => "/^[0-9]{4}(-[0-9]{3})?$/", 138 | 'by', 'cn', 'ec', 'in', 'kz', 'kg', 'ro', 'ru', 'sg', 'tj', 'zu' => "/^[0-9]{6}$/", 139 | 'ca' => "/^[a-z][0-9][a-z] [0-9][a-z]([0-9])?$/i", 140 | 'az' => "/^[0-9]{4}([0-9]{2})?$/", 141 | 'sz' => "/^[a-z]{1}[0-9]{3}$/i", 142 | 'tw' => "/^[0-9]{3}([0-9]{2})?$/", 143 | 'gb' => "/^(([a-z][0-9])|([a-z][0-9]{2})|([a-z][0-9][a-z])|([a-z]{2}[0-9])" . 144 | "|([a-z]{2}[0-9]{2})|([a-z]{2}[0-9][a-z])) [0-9][a-z]{2}$/i", 145 | 'ie' => "/^[A-Za-z][A-Za-z0-9]{2} [A-Za-z0-9]{4}$/i", 146 | default => null, 147 | }; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/Rules/Semver.php: -------------------------------------------------------------------------------- 1 | words($value) as $word) { 19 | if (!$this->isValidWord($word)) { 20 | return false; 21 | } 22 | } 23 | 24 | return true; 25 | } 26 | 27 | /** 28 | * Get array of words from current value 29 | * 30 | * @return array 31 | */ 32 | private function words(mixed $value): array 33 | { 34 | return explode(" ", (string) $value); 35 | } 36 | 37 | /** 38 | * Determine if given word starts with upper case letter or number 39 | */ 40 | private function isValidWord(string $word): bool 41 | { 42 | return (bool) preg_match("/^[\p{Lu}0-9]/u", $word); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Rules/Ulid.php: -------------------------------------------------------------------------------- 1 | ulidTooLarge($value); 33 | } 34 | 35 | /** 36 | * Determine if current ulid has exceeded maximum size 37 | */ 38 | private function ulidTooLarge(string $value): bool 39 | { 40 | return intval($value[0]) > 7; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Rules/Uppercase.php: -------------------------------------------------------------------------------- 1 | '.(ISIN) دولي صالح للأوراق المالية :attribute يجب أن يكون رقم تعريف', 7 | 'iban' => '.(IBAN) رقم حساب مصرفي دولي صالح :attribute يجب أن يكون', 8 | 'bic' => '.(BIC) ليس رمز معرف تجاري صالحًا :attribute', 9 | 'hexadecimalcolor' => '.رمزً لونياً سداسيً عشرياً صالحاً :attribute يجب أن يكون', 10 | 'creditcard' => '.رقمً صالحاً لبطاقة الائتمان :attribute يجب أن يكون', 11 | 'isbn' => '.(ISBN) رقم كتاب معياري دولياً صالحاً :attribute يجب أن يكون', 12 | 'username' => '.اسم مستخدم صالحاً :attribute يجب أن يكون', 13 | 'htmlclean' => '.ممنوع HTML تحتوي على كود :attribute قيمة', 14 | 'domainname' => '.يجب ان يكون اسم نطاق صحيح :attribute', 15 | 'jwt' => '.JSON Web Token لا تتوافق مع تنسيق :attribute قيمة', 16 | 'imei' => '.(IMEI) معرّفاً صالحاً لجهاز الهاتف المحمول :attribute يجب أن تكون قيمة', 17 | 'macaddress' => '.صالحاً MAC ليس عنوان :attribute قيمة', 18 | 'slug' => '.ليست نصاً قصيراً صديقاً لتحسين محركات البحث :attribute قيمة', 19 | 'luhn' => '.Luhn بأستخدام خوارزمية :attribute لا يمكن التحقق من قيمة', 20 | 'base64' => '.Base64 ليست بتشفير :attribute قيمة', 21 | 'issn' => '.(issn) رقم تسلسلي قياسي دولي صالح :attribute يجب أن يكون', 22 | 'lowercase' => '.أحرف صغيرة :attribute يجب أن تكون قيمة', 23 | 'uppercase' => '.أحرف كبيرة :attribute يجب أن تكون قيمة', 24 | 'titlecase' => '.بحرف كبير :attribute يجب أن تبدأ جميع الكلمات في', 25 | 'snakecase' => '.Snakecase في حالة :attribute يجب تنسيق قيمة', 26 | 'kebabcase' => '.Kebabcase في حالة :attribute يجب تنسيق قيمة', 27 | 'camelcase' => '.Camelcase في حالة :attribute يجب تنسيق قيمة', 28 | 'cidr' => '.صالحاً CIDR تدوين :attribute يجب أن يكون', 29 | 'datauri' => 'يجب أن يكون :attribute data url صالحًا', 30 | 'ulid' => 'يجب أن يكون :attribute ULID صالحًا', 31 | 'ean' => 'يجب أن يكون :attribute EAN صالحًا', 32 | 'gtin' => 'يجب أن يكون :attribute GTIN صالحًا', 33 | 'postalcode' => 'يجب أن تكون القيمة :attribute رمزًا بريديًا صالحًا.', 34 | 'mimetype' => 'لا تحتوي القيمة :attribute على نوع وسائط إنترنت صالح (نوع MIME)', 35 | 'semver' => 'القيمة :attribute ليست رقم إصدار بمعنى مواصفات الإصدار الدلالية.', 36 | ]; 37 | -------------------------------------------------------------------------------- /src/lang/bn/validation.php: -------------------------------------------------------------------------------- 1 | 'এই :attribute টি একটি বৈধ আন্তর্জাতিক সিকিউরিটিজ আইডেন্টিফিকেশন নম্বর হতে হবে (ISIN).', 7 | 'iban' => 'এই :attribute টি অবশ্যই একটি বৈধ আন্তর্জাতিক ব্যাঙ্ক অ্যাকাউন্ট নম্বর হতে হবে (IBAN).', 8 | 'bic' => 'এই :attribute টি বৈধ ব্যবসা শনাক্তকারী কোড নয় (BIC).', 9 | 'hexadecimalcolor' => 'এই :attribute টি অবশ্যই একটি বৈধ হেক্সাডেসিমেল কালার কোড হতে হবে.', 10 | 'creditcard' => 'এই :attribute টি একটি বৈধ ক্রেডিটকার্ড নম্বর হতে হবে.', 11 | 'isbn' => 'এই :attribute টি অবশ্যই একটি বৈধ আন্তর্জাতিক স্ট্যান্ডার্ড বুক নম্বর হতে হবে (ISBN).', 12 | 'username' => 'এই :attribute টি একজন বৈধ ব্যবহারকারীর নাম হতে হবে.', 13 | 'htmlclean' => 'এই :attribute টিতে নিষিদ্ধ HTML কোড রয়েছে.', 14 | 'domainname' => 'এই :attribute টি একটি সঠিক ডোমেইন নাম হতে হবে.', 15 | 'jwt' => 'এই :attribute টি JSON ওয়েব টোকেন বিন্যাসের সাথে সঙ্গতিপূর্ণ নয়', 16 | 'imei' => 'এই :attribute টি একটি বৈধ মোবাইল ইকুইপমেন্ট আইডেন্টিটি হতে হবে (IMEI).', 17 | 'macaddress' => 'এই :attribute টি কোনো বৈধ MAC এড্রেস নয়.', 18 | 'slug' => 'এই :attribute টি কোন SEO-বান্ধব সংক্ষিপ্ত টেক্সট নয়.', 19 | 'semver' => 'এই :attribute টি শব্দার্থিক সংস্করণ ব্যবহার করে কোনো সংস্করণ নম্বর নয়.', 20 | 'luhn' => 'এই :attribute টি Luhn অ্যালগরিদম ব্যবহার করে যাচাই করা যাবে না.', 21 | 'base64' => 'এই :attribute টি বেস64 এনকোডেড নয়.', 22 | 'issn' => 'এই :attribute টি একটি বৈধ আন্তর্জাতিক স্ট্যান্ডার্ড সিরিয়াল নম্বর হতে হবে (ISSN).', 23 | 'lowercase' => 'এই :attribute টিতে শুধুমাত্র ছোট হাতের অক্ষর থাকতে পারে.', 24 | 'uppercase' => 'এই :attribute টিতে শুধুমাত্র বড় হাতের অক্ষর থাকতে পারে.', 25 | 'titlecase' => 'এই :attribute টিতে সমস্ত শব্দ বড় অক্ষর দিয়ে শুরু হওয়া আবশ্যক.', 26 | 'snakecase' => 'এই :attribute টি অবশ্যই স্নেক কেসে ফরম্যাট করতে হবে.', 27 | 'kebabcase' => 'এই :attribute টি অবশ্যই কেবাব কেসে ফরম্যাট করতে হবে.', 28 | 'camelcase' => 'এই :attribute টি অবশ্যই ক্যামেল কেসে ফরম্যাট করতে হবে.', 29 | 'cidr' => 'এই :attribute টি একটি বৈধ CIDR স্বরলিপি হতে হবে.', 30 | 'datauri' => 'এই :attribute টি অবশ্যই একটি বৈধ ডেটা ইউআরএল হতে হবে.', 31 | 'ulid' => 'এই :attribute টি একটি বৈধ ULID নয়.', 32 | 'ean' => 'এই :attribute টি একটি বৈধ ইউরোপীয় নিবন্ধ সংখ্যা নয় (EAN).', 33 | 'gtin' => 'এই :attribute টি একটি বৈধ গ্লোবাল ট্রেড আইটেম নম্বর নয় (GTIN).', 34 | 'postalcode' => 'এই :attribute টি একটি বৈধ পোস্টাল কোড হতে হবে.', 35 | 'mimetype' => 'এই :attribute টিতে একটি বৈধ ইন্টারনেট মিডিয়া টাইপ নেই (MIME-Type).', 36 | ]; 37 | -------------------------------------------------------------------------------- /src/lang/de/validation.php: -------------------------------------------------------------------------------- 1 | 'Der Wert :attribute ist keine International Securities Identification Number (ISIN).', 7 | 'iban' => 'Der Wert :attribute ist keine International Bank Account Number (IBAN).', 8 | 'bic' => 'Der Wert :attribute muss einen gültigen Business Identifier Code (BIC) enthalten.', 9 | 'hexadecimalcolor' => 'Der Wert :attribute muss einen gültigen hexadezimalen Farbwert enthalten.', 10 | 'creditcard' => 'Der Wert :attribute ist keine gültige Kreditkartennummer.', 11 | 'isbn' => 'Der Wert :attribute muss eine gültige International Standard Book Number (ISBN) enthalten.', 12 | 'username' => 'Der Wert :attribute enthält keinen gültigen Benutzernamen.', 13 | 'htmlclean' => 'Der Wert :attribute enthält nicht erlaubten HTML Code.', 14 | 'domainname' => 'Der Wert :attribute muss einen Domainnamen enthalten.', 15 | 'jwt' => 'Der Wert :attribute entspricht nicht dem JSON Web Token Format.', 16 | 'imei' => 'Der Wert :attribute ist keine gültige Mobile Equipment Identity (IMEI) Nummer.', 17 | 'macaddress' => 'Der Wert :attribute ist keine gültige MAC Addresse.', 18 | 'slug' => 'Der Wert :attribute ist kein suchmaschinenfreundlicher Kurzname.', 19 | 'semver' => 'Der Wert :attribute ist keine Versionsnummer im Sinne der Semantic Versioning Spezifikation.', 20 | 'luhn' => 'Der Wert :attribute kann nicht nach dem Luhn-Algorithmus verifiziert werden.', 21 | 'base64' => 'Der Wert :attribute ist nicht nach dem Base64 Verfahren kodiert.', 22 | 'issn' => 'Der Wert :attribute ist keine gültige internationale ' . 23 | 'Standardnummer für fortlaufende Sammelwerke (ISSN).', 24 | 'lowercase' => 'Der Inhalt :attribute darf nur aus Kleinbuchstaben bestehen.', 25 | 'uppercase' => 'Der Inhalt :attribute darf nur aus Großbuchstaben bestehen.', 26 | 'titlecase' => 'Alle Wörter aus :attribute müssen mit Großbuchstaben beginnen.', 27 | 'snakecase' => 'Der Inhalt :attribute muss in Snake Case formatiert sein.', 28 | 'kebabcase' => 'Der Inhalt :attribute muss in Kebab Case formatiert sein.', 29 | 'camelcase' => 'Der Inhalt :attribute muss in Camel Case formatiert sein.', 30 | 'cidr' => ':attribute ist keine gültige CIDR Notation.', 31 | 'datauri' => ':attribute ist keine gültige Data-URL.', 32 | 'ulid' => ':attribute ist keine gültige ULID.', 33 | 'ean' => 'Der Wert :attribute ist keine gültige European Article Number (EAN).', 34 | 'gtin' => 'Der Wert :attribute ist keine gültige Global Trade Item Number (GTIN).', 35 | 'postalcode' => 'Der Wert :attribute muss eine gültige Postleitzahl sein.', 36 | 'mimetype' => 'Der Wert :attribute einhält keinen gültigen Internet Media Type (MIME-Type).', 37 | 'austrianinsurancenumber' => 'Der Wert :attribute enthält keine gültige österreichische Versicherungsnummer', 38 | 'grid' => 'Der Wert :attribute enthält keinen gültige Global Release Identifier (GRid).', 39 | 'hslcolor' => 'Der Wert :attribute enthält keinen gültigen HSL-Farbwert.', 40 | 'hsvcolor' => 'Der Wert :attribute enthält keinen gültigen HSV-Farbwert.', 41 | 'latitude' => 'Der Wert :attribute enthält keine gültige geographische Breite.', 42 | 'longitude' => 'Der Wert :attribute enthält keine gültige geographische Länge.', 43 | 'latlng' => 'Der Wert :attribute ist kein gültiges geographisches Koordinatenpaar.', 44 | ]; 45 | -------------------------------------------------------------------------------- /src/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be a valid International Securities Identification Number (ISIN).', 7 | 'iban' => 'The :attribute must be a valid International Bank Account Number (IBAN).', 8 | 'bic' => 'The :attribute is not a valid Business Identifier Code (BIC).', 9 | 'hexadecimalcolor' => 'The :attribute must be a valid hexadecimal color code.', 10 | 'creditcard' => 'The :attribute must be a valid creditcard number.', 11 | 'isbn' => ':attribute must be a valid International Standard Book Number (ISBN).', 12 | 'username' => 'The value :attribute must be a valid username.', 13 | 'htmlclean' => 'The value :attribute contains forbidden HTML code.', 14 | 'domainname' => ':attribute must be a well formed domainname.', 15 | 'jwt' => 'The value :attribute does not correspond to the JSON Web Token Format', 16 | 'imei' => 'The value :attribute must be a valid Mobile Equipment Identity (IMEI).', 17 | 'macaddress' => 'The value :attribute is no valid MAC address.', 18 | 'slug' => 'The value :attribute is no SEO-friendly short text.', 19 | 'semver' => 'The value :attribute is no version number using Semantic Versioning.', 20 | 'luhn' => 'The value :attribute cannot be verified using the Luhn algorithm.', 21 | 'base64' => 'The value :attribute is not Base64 encoded.', 22 | 'issn' => 'The value :attribute must be a valid International Standard Serial Number (ISSN).', 23 | 'lowercase' => 'The content :attribute may only consist of lowercase letters.', 24 | 'uppercase' => 'The content :attribute may only consist of uppercase letters.', 25 | 'titlecase' => 'All words from :attribute must begin with capital letters.', 26 | 'snakecase' => 'The content :attribute must be formatted in Snake case.', 27 | 'kebabcase' => 'The content :attribute must be formatted in Kebab case.', 28 | 'camelcase' => 'The content :attribute must be formatted in Camel case.', 29 | 'cidr' => 'The :attribute must be a valid CIDR notation.', 30 | 'datauri' => 'The :attribute must be a valid data url.', 31 | 'ulid' => 'The :attribute is not a valid ULID.', 32 | 'ean' => 'The :attribute is not a valid European Article Number (EAN).', 33 | 'gtin' => 'The :attribute is not a valid Global Trade Item Number (GTIN).', 34 | 'postalcode' => 'The value :attribute must be a valid postal code.', 35 | 'mimetype' => 'The value :attribute does not contain a valid Internet Media Type (MIME-Type).', 36 | 'austrianinsurancenumber' => 'The value :attribute does not contain a valid austrian insurance number.', 37 | 'grid' => 'The value :attribute must be a valid Global Release Identifier (GRid).', 38 | 'hslcolor' => 'The value :attribute must be a valid HSL color.', 39 | 'hsvcolor' => 'The value :attribute must be a valid HSV color.', 40 | 'latitude' => 'The value :attribute must be a valid geographical latitude.', 41 | 'longitude' => 'The value :attribute must be a valid geographical longitude.', 42 | 'latlng' => 'The value :attribute must be valid geographical coordinates.', 43 | ]; 44 | -------------------------------------------------------------------------------- /src/lang/es/validation.php: -------------------------------------------------------------------------------- 1 | ':attribute debe ser un número ISIN válido', 7 | 'iban' => ':attribute debe ser un número IBAN válido.', 8 | 'bic' => ':attribute no es un código BIC válido.', 9 | 'hexadecimalcolor' => ':attribute debe ser un código de color hexadecimal válido.', 10 | 'creditcard' => ':attribute debe ser un número de tarjeta de crédito válido.', 11 | 'isbn' => ':attribute debe ser un código ISBN válido.', 12 | 'username' => 'El valor de :attribute debe ser un nombre de usuario válido.', 13 | 'htmlclean' => 'El valor de :attribute contiene código HTML no permitido.', 14 | 'domainname' => ':attribute debe ser un nombre de dominio con el formato correcto.', 15 | 'jwt' => 'El valor de :attribute no corresponde con el formato de token web de JSON (JWT)', 16 | 'imei' => 'El valor de :attribute debe ser un código IMEI válido.', 17 | 'macaddress' => 'El valor de :attribute no es una dirección MAC válida.', 18 | 'slug' => 'El valor de :attribute no es un texto corto amigable con SEO.', 19 | 'semver' => 'El valor de :attribute no es un número de versión válido según el versionamiento semántico.', 20 | 'luhn' => 'El valor de :attribute no puede ser verificado usando el algoritmo de Luhn.', 21 | 'base64' => 'El valor de :attribute no está codificado con Base64.', 22 | 'issn' => 'El valor de :attribute debe ser un número ISSN válido.', 23 | 'lowercase' => 'El contenido de :attribute debe consistir solo de letras minúsculas .', 24 | 'uppercase' => 'El contenido de :attribute debe consistir solo de letras mayúsculas.', 25 | 'titlecase' => 'Todas las palabras de :attribute deben comenzar con letra mayúscula.', 26 | 'snakecase' => 'El contenido de :attribute debe estar en el formato Snake case.', 27 | 'kebabcase' => 'El contenido de :attribute debe estar en el formato Kebab case', 28 | 'camelcase' => 'El contenido de :attribute debe estar en el formato Camel case', 29 | 'cidr' => ':attribute debe estar en notación CIDR válida.', 30 | 'datauri' => ':attribute debe ser un url de datos válido .', 31 | 'ulid' => ':attribute no es un ULID válido.', 32 | 'ean' => ':attribute no es un EAN válido.', 33 | 'gtin' => ':attribute no es un número GTIN válido.', 34 | 'postalcode' => 'El valor de :attribute debe ser un código postal válido.', 35 | 'mimetype' => 'El valor de :attribute no contiene un tipo de media de internet (MIME-Type) válido.', 36 | 'austrianinsurancenumber' => 'El valor de :attribute contiene un número de seguro austriaco válido.', 37 | 'grid' => 'El valor de :attribute no contiene un Global Release Identifier (GRid) válido.', 38 | 'hslcolor' => ':attribute no es un valor de color HSL válido.', 39 | 'hsvcolor' => ':attribute no es un valor de color HSV válido.', 40 | 'latitude' => ':attribute no es una latitud válida.', 41 | 'longitude' => ':attribute no es una longitud geográfica válida.', 42 | 'latlng' => ':attribute no es un par de coordenadas geográficas válido.', 43 | ]; 44 | -------------------------------------------------------------------------------- /src/lang/fa/validation.php: -------------------------------------------------------------------------------- 1 | 'مقدار :attribute باید یک کد ISIN معتبر باشد.', 7 | 'iban' => 'مقدار :attribute باید یک شماره شبا معتبر باشد.', 8 | 'bic' => 'مقدار :attribute باید یک کد BIC معتبر باشد.', 9 | 'hexadecimalcolor' => 'مقدار :attribute باید یک کد رنگ HEX معتبر باشد.', 10 | 'creditcard' => 'مقدار :attribute باید یک شماره کارت اعتباری معتبر باشد.', 11 | 'isbn' => 'مقدار :attribute باید یک شماره ISBN معتبر باشد.', 12 | 'username' => 'مقدار :attribute باید یک نام کاربری معتبر باشد.', 13 | 'htmlclean' => 'مقدار :attribute باید یک متن HTML معتبر باشد.', 14 | 'domainname' => 'مقدار :attribute باید یک نام دامنه معتبر باشد.', 15 | 'jwt' => 'مقدار :attribute باید یک توکن JWT معتبر باشد.', 16 | 'imei' => 'مقدار :attribute باید یک شماره IMEI معتبر باشد.', 17 | 'macaddress' => 'مقدار :attribute باید یک آدرس MAC معتبر باشد.', 18 | 'slug' => 'مقدار :attribute باید یک نام کوتاه موتور جستجو باشد.', 19 | 'semver' => 'مقدار :attribute باید یک شماره نسخه معتبر باشد.', 20 | 'luhn' => 'مقدار :attribute باید یک شماره Luhn معتبر باشد.', 21 | 'base64' => 'مقدار :attribute باید یک مقدار Base64 معتبر باشد.', 22 | 'issn' => 'مقدار :attribute باید یک شماره ISSN معتبر باشد.', 23 | 'lowercase' => 'مقدار :attribute باید فقط شامل حروف کوچک باشد.', 24 | 'uppercase' => 'مقدار :attribute باید فقط شامل حروف بزرگ باشد.', 25 | 'titlecase' => 'همه کلمات :attribute باید با حروف بزرگ آغاز شوند.', 26 | 'snakecase' => 'مقدار :attribute باید به صورت Snake Case باشد.', 27 | 'kebabcase' => 'مقدار :attribute باید به صورت Kebab Case باشد.', 28 | 'camelcase' => 'مقدار :attribute باید به صورت Camel Case باشد.', 29 | 'cidr' => 'مقدار :attribute باید یک نمایش CIDR معتبر باشد.', 30 | 'datauri' => 'مقدار :attribute باید یک URL داده معتبر باشد.', 31 | 'ulid' => 'مقدار :attribute باید یک ULID معتبر باشد.', 32 | 'ean' => 'مقدار :attribute باید یک EAN معتبر باشد.', 33 | 'gtin' => 'مقدار :attribute باید یک GTIN معتبر باشد.', 34 | 'postalcode' => 'مقدار :attribute باید یک کد پستی معتبر باشد.', 35 | 'mimetype' => 'مقدار :attribute باید یک نوع رسانه اینترنتی معتبر باشد.', 36 | ]; 37 | -------------------------------------------------------------------------------- /src/lang/fi/validation.php: -------------------------------------------------------------------------------- 1 | ':attribute tulee olla kelvollinen International Securities Identification Number (ISIN).', 7 | 'iban' => ':attribute tulee olla kelvollinen International Bank Account Number (IBAN).', 8 | 'bic' => ':attribute tulee olla kelvollinen Business Identifier Code (BIC).', 9 | 'hexadecimalcolor' => ':attribute tulee olla kelvollinen heksadesimaali värikoodi.', 10 | 'creditcard' => ':attribute tulee olla kelvollinen luottokortin numero.', 11 | 'isbn' => ':attribute tulee olla kelvollinen International Standard Book Number (ISBN).', 12 | 'username' => ':attribute tulee olla kelvollinen käyttäjänimi.', 13 | 'htmlclean' => ':attribute sisältää kiellettyä HTML-koodia.', 14 | 'domainname' => ':attribute tulee olla kelvollinen verkkoalueen nimi.', 15 | 'jwt' => ':attribute ei vastaa JSON Web Token muotoa', 16 | 'imei' => ':attribute tulee olla kelvollinen Mobile Equipment Identity (IMEI).', 17 | 'macaddress' => ':attribute tulee olla kelvollinen MAC-osoite.', 18 | 'slug' => ':attribute tulee olla kelvollinen polkutunnus', 19 | 'semver' => ':attribute tulee olla kelvollinen semanttisen versionumeroinnin versionumero.', 20 | 'luhn' => ':attribute tarkistussummaa ei voida vahvistaa Luhnin algoritmilla.', 21 | 'base64' => ':attribute tulee olla kelvollinen base64-muotoinen arvo.', 22 | 'issn' => ':attribute tulee olla kelvollinen International Standard Serial Number (ISSN).', 23 | 'lowercase' => ':attribute voi sisältää vain pieniä kirjaimia.', 24 | 'uppercase' => ':attribute voi sisältää vain isoja kirjaimia.', 25 | 'titlecase' => ':attribute kaikkien sanojen tulee alkaa isolla alkukirjaimella.', 26 | 'kebabcase' => ':attribute tulee olla käytetty kebab case kirjoitusasua.', 27 | 'snakecase' => ':attribute tulee olla käytetty snake case kirjoitusasua.', 28 | 'camelcase' => ':attribute tulee olla käytetty camel case kirjoitusasua.', 29 | 'cidr' => ':attribute tulee olla kelvollinen CIDR muoto.', 30 | 'datauri' => ':attribute on oltava kelvollinen data-URL.', 31 | 'ulid' => ':attribute on oltava kelvollinen ULID.', 32 | 'ean' => ':attribute on oltava kelvollinen EAN.', 33 | 'gtin' => ':attribute on oltava kelvollinen GTIN.', 34 | 'postalcode' => 'Arvo :attribute on oltava kelvollinen postinumero.', 35 | 'mimetype' => 'Arvo :attribute ei sisällä kelvollista Internet -mediatyyppiä (MIME-Type).', 36 | 'grid' => ':attribute on oltava kelvollinen Global Release Identifier (GRid).', 37 | 'hslcolor' => ':attribute ei ole kelvollinen HSL-väriarvo', 38 | 'hsvcolor' => ':attribute ei ole kelvollinen HSV-väriarvo', 39 | 'latitude' => ':attribute ei ole kelvollinen leveysaste.', 40 | 'longitude' => ':attribute ei ole kelvollinen maantieteellinen pituusaste.', 41 | 'latlng' => ':attribute ei ole kelvollinen maantieteellinen koordinaattipari.', 42 | ]; 43 | -------------------------------------------------------------------------------- /src/lang/fr/validation.php: -------------------------------------------------------------------------------- 1 | 'Le champ :attribute doit être un code ISIN valide.', 7 | 'iban' => 'Le champ :attribute doit être un code IBAN valide.', 8 | 'bic' => 'Le champ :attribute doit être un code BIC valide.', 9 | 'hexadecimalcolor' => 'Le champ :attribute doit être un code couleur hexadécimal valide.', 10 | 'creditcard' => 'Le champ :attribute doit être un numéro de carte de crédit valide.', 11 | 'isbn' => 'Le champ :attribute doit être un numéro ISBN valide.', 12 | 'username' => 'La valeur de :attribute doit être un pseudonyme valide : chaine alphanumérique entre 3' . 13 | ' et 20 caractères, débutant obligatoirement par une lettre, acceptant les tirets et tirets bas.', 14 | 'htmlclean' => 'La valeur de :attribute ne doit pas contenir de code HTML.', 15 | 'domainname' => ':attribute doit être un nom de domaine valide.', 16 | 'jwt' => 'La valeur :attribute ne correspond pas au format JSON Web Token.', 17 | 'imei' => 'La valeur :attribute doit être une code IMEI valide.', 18 | 'macaddress' => 'La valeur :attribute doit être une adresse MAC valide.', 19 | 'slug' => 'Le champ ::attribute doit respecter le format de paramètre d\'URL optimisé pour le ' . 20 | 'SEO : mots composés de caractères alphanumériques, séparés par des tirets.', 21 | 'semver' => 'La champ :attribute doit être un numéro de version ' . 22 | 'respectant la norme de gestion sémantique de version.', 23 | 'luhn' => 'Le champ :attribute n\'est pas vérifié par l\'algorithme de Luhn.', 24 | 'base64' => 'Le champ :attribute doit être un code Base64 valide.', 25 | 'issn' => 'La valeur :attribute doit être un numéro ISSN valide.', 26 | 'lowercase' => 'Le champ :attribute ne doit pas comporter de lettres majuscules.', 27 | 'uppercase' => 'Le champ :attribute ne doit pas comporter de lettres minuscules.', 28 | 'titlecase' => 'Le champ :attribute doit être formaté en "Title Case" : mots composés de ' . 29 | 'caractères alphanumériques, commençant chacun par une lettre majuscule, séparés par des espaces.', 30 | 'snakecase' => 'Le champ :attribute doit être formaté en "snake_case" : mots composés de ' . 31 | ' lettres minuscules, séparés par des tirets bas.', 32 | 'kebabcase' => 'Le champ :attribute doit être formaté en "kebab-case" : mots composés de ' . 33 | ' lettres minuscules, séparés par des tirets.', 34 | 'camelcase' => 'Le champ :attribute doit être formaté en "CamelCase" : mots composés de ' . 35 | ' lettres minuscules commençant chacun par une lettre majuscule, liés les uns aux autres sans espace.', 36 | 'cidr' => 'Le champ :attribute doit être un format CIDR valide.', 37 | 'datauri' => 'Le :attribute doit être un Data URL valide.', 38 | 'ulid' => 'Le :attribute doit être un ULID valide.', 39 | 'ean' => 'Le :attribute doit être un EAN valide.', 40 | 'gtin' => 'Le :attribute doit être un GTIN valide.', 41 | 'postalcode' => 'La valeur :attribute doit être un code postal valide.', 42 | 'mimetype' => 'La valeur :attribute ne contient pas de type de média Internet valide (type MIME).', 43 | 'austrianinsurancenumber' => 'La valeur :attribute ne contient pas de numéro d\'assurance autrichien valide.', 44 | 'grid' => 'Le :attribute doit être un Global Release Identifier (GRid) valide.', 45 | 'hslcolor' => ':attribute n\'est pas une valeur de couleur HSL valide', 46 | 'hsvcolor' => ':attribute n\'est pas une valeur de couleur HSV valide', 47 | 'latitude' => ':attribute n\'est pas une latitude valide.', 48 | 'longitude' => ':attribute n\'est pas une longitude valide.', 49 | 'latlng' => ':attribute n\'est pas une paire de coordonnées géographiques valables.', 50 | ]; 51 | -------------------------------------------------------------------------------- /src/lang/id/validation.php: -------------------------------------------------------------------------------- 1 | ':attribute harus berupa International Securities Identification Number (ISIN) yang valid.', 7 | 'iban' => ':attribute harus berupa International Bank Account Number (IBAN) yang valid.', 8 | 'bic' => ':attribute bukan Business Identifier Code (BIC) yang valid.', 9 | 'hexadecimalcolor' => ':attribute harus berupa kode warna hexadecimal yang valid.', 10 | 'creditcard' => ':attribute harus berupa nomor kartu kredit yang valid.', 11 | 'isbn' => ':attribute harus berupa International Standard Book Number (ISBN) yang valid.', 12 | 'username' => 'Nilai :attribute harus berupa username yang valid.', 13 | 'htmlclean' => 'Nilai :attribute mengandung kode HTML yang tidak diijinkan.', 14 | 'domainname' => ':attribute harus berupa struktur nama domain yang benar.', 15 | 'jwt' => 'Nilai :attribute tidak sesuai dengan format JSON Web Token', 16 | 'imei' => 'Nilai :attribute harus berupa Mobile Equipment Identity (IMEI) yang valid.', 17 | 'macaddress' => 'Nilai :attribute bukan MAC address yang valid.', 18 | 'slug' => 'Nilai :attribute bukan teks pendek yang baik untuk SEO.', 19 | 'semver' => 'Nilai :attribute tidak mengandung nomor versi yang menggunakan Semantic Versioning.', 20 | 'luhn' => 'Nilai :attribute tidak dapat diverifikasi dengan Luhn algorithm.', 21 | 'base64' => 'Nilai :attribute bukan merupakan Base64 encoded.', 22 | 'issn' => 'Nilai :attribute harus berupa International Standard Serial Number (ISSN) yang valid.', 23 | 'lowercase' => 'Isi :attribute hanya boleh mengandung huruf kecil.', 24 | 'uppercase' => 'Isi :attribute hanya boleh mengandung huruf besar.', 25 | 'titlecase' => 'Semua kata pada :attribute harus dimulai dengan huruf kapital.', 26 | 'snakecase' => 'Isi :attribute harus berupa format Snake case.', 27 | 'kebabcase' => 'Isi :attribute harus berupa format Kebab case.', 28 | 'camelcase' => 'Isi :attribute harus berupa format Camel case.', 29 | 'cidr' => ':attribute harus berupa format CIDR yang valid.', 30 | 'datauri' => ':attribute harus berupa url data yang valid.', 31 | 'ulid' => ':attribute harus berupa format ULID yang valid.', 32 | 'ean' => ':attribute harus berupa format EAN yang valid.', 33 | 'gtin' => ':attribute harus berupa format GTIN yang valid.', 34 | 'postalcode' => 'Nilai :attribute harus berupa kode pos yang valid.', 35 | 'mimetype' => 'Nilai :attribute tidak berisi Jenis Media Internet yang valid (jenis MIME).', 36 | 'grid' => 'Nilai :attribute harus berupa Global Release Identifier (GRid) yang valid.', 37 | ]; 38 | -------------------------------------------------------------------------------- /src/lang/nl/validation.php: -------------------------------------------------------------------------------- 1 | ':attribute moet een geldig International Securities Identification Number (ISIN) zijn.', 7 | 'iban' => ':attribute moet een geldig International Bank Account Number (IBAN) zijn.', 8 | 'bic' => ':attribute moet een geldig Business Identifier Code (BIC) zijn.', 9 | 'hexadecimalcolor' => ':attribute moet een geldige hexadecimale kleurcode zijn.', 10 | 'creditcard' => ':attribute moet een geldig creditcardnummer zijn.', 11 | 'isbn' => ':attribute moet een geldig International Standard Book Number (ISBN) zijn.', 12 | 'username' => ':attribute moet een geldige gebruikersnaam zijn.', 13 | 'htmlclean' => ':attribute bevat verboden HTML code.', 14 | 'domainname' => ':attribute moet een geldige domeinnaam zijn.', 15 | 'jwt' => ':attribute komt niet overeen met het JSON Web Token (JWT) formaat', 16 | 'imei' => ':attribute moet een geldige Mobile Equipment Identity (IMEI) zijn.', 17 | 'macaddress' => ':attribute is geen geldig MAC-adres.', 18 | 'slug' => ':attribute is geen SEO-vriendelijke korte tekst.', 19 | 'semver' => ':attribute is geen versienummer dat Semantic Versioning gebruikt.', 20 | 'luhn' => ':attribute kan niet worden geverifieerd met behulp van het Luhn-algoritme.', 21 | 'base64' => ':attribute is niet gecodeerd met de Base64-methode.', 22 | 'issn' => ':attribute moet een geldige International Standard Serial Number (ISSN) zijn.', 23 | 'lowercase' => ':attribute mag alleen bestaan uit kleine letters.', 24 | 'uppercase' => ':attribute mag alleen bestaan uit hoofdletters.', 25 | 'titlecase' => 'Alle woorden uit :attribute moeten beginnen met hoofdletters.', 26 | 'snakecase' => ':attribute moet zijn opgemaakt in Snake case.', 27 | 'kebabcase' => ':attribute moet worden opgemaakt in Kebab case.', 28 | 'camelcase' => ':attribute moet worden opgemaakt in Camel case.', 29 | 'cidr' => ':attribute moet een geldig CIDR notatie zijn.', 30 | 'datauri' => ':attribute moet een geldige Data-URL zijn.', 31 | 'ulid' => ':attribute is geen geldig ULID.', 32 | 'ean' => ':attribute is geen geldig European Article Number (EAN).', 33 | 'gtin' => ':attribute is geen geldig Global Trade Item Number (GTIN).', 34 | 'postalcode' => ':attribute moet een geldige postcode zijn.', 35 | 'mimetype' => ':attribute bevat geen geldig internetmediatype (MIME-type).', 36 | 'austrianinsurancenumber' => 'De waarde :attribute bevat geen geldig Oostenrijks verzekeringsnummer.', 37 | 'grid' => ':attribute moet een geldige Global Release Identifier (GRid) zijn.', 38 | 'hslcolor' => ':attribute is geen geldige HSL-kleurwaarde', 39 | 'hsvcolor' => ':attribute is geen geldige HSV-kleurwaarde', 40 | 'latitude' => ':attribute is geen geldige breedtegraad.', 41 | 'longitude' => ':attribute is geen geldige lengtegraad.', 42 | 'latlng' => ':attribute geen geldig geografisch coördinatenpaar is.', 43 | ]; 44 | -------------------------------------------------------------------------------- /src/lang/uk/validation.php: -------------------------------------------------------------------------------- 1 | 'Поле :attribute повинно містити дійсний міжнародний ідентифікатор цінних паперів (ISIN).', 7 | 'iban' => 'Поле :attribute повинно містити дійсний міжнародний номер банківського рахунку (IBAN).', 8 | 'bic' => 'Поле :attribute не є дійсним бізнес-ідентифікаційним кодом (BIC).', 9 | 'hexadecimalcolor' => 'Поле :attribute повинно містити дійсний шістнадцятковий код кольору.', 10 | 'creditcard' => 'Поле :attribute повинно містити дійсний номер кредитної картки.', 11 | 'isbn' => 'Поле :attribute повинно містити дійсний міжнародний стандартний книжковий номер (ISBN).', 12 | 'username' => 'Значення :attribute повинно бути дійсним ім’ям користувача.', 13 | 'htmlclean' => 'Значення :attribute містить заборонений код HTML.', 14 | 'domainname' => 'Поле :attribute повинно бути дійсним доменним ім’ям.', 15 | 'jwt' => 'Значення :attribute не відповідає формату JSON Web Token.', 16 | 'imei' => 'Поле :attribute повинно містити дійсний ідентифікатор обладнання мобільного зв’язку (IMEI).', 17 | 'macaddress' => 'Значення :attribute не є дійсною адресою MAC.', 18 | 'slug' => 'Значення :attribute не є коротким текстом, який підходить для SEO.', 19 | 'semver' => 'Значення :attribute не є номером версії відповідно до семантичного відображення.', 20 | 'luhn' => 'Значення :attribute не може бути перевірене алгоритмом Луна.', 21 | 'base64' => 'Значення :attribute не є кодуванням Base64.', 22 | 'issn' => 'Поле :attribute повинно містити дійсний міжнародний стандартний серійний номер (ISSN).', 23 | 'lowercase' => 'Зміст :attribute може містити тільки строчні літери.', 24 | 'uppercase' => 'Зміст :attribute може містити тільки прописні літери.', 25 | 'titlecase' => 'Усі слова з :attribute повинні починатися з великих літер.', 26 | 'snakecase' => 'Зміст :attribute повинен бути в форматі Snake case.', 27 | 'kebabcase' => 'Зміст :attribute повинен бути в форматі Kebab case.', 28 | 'camelcase' => 'Зміст :attribute повинен бути в форматі Camel case.', 29 | 'cidr' => 'Поле :attribute повинно містити дійсний CIDR-префікс.', 30 | 'datauri' => 'Поле :attribute повинно містити дійсну URL-адресу або encoded data.', 31 | 'ulid' => 'Поле :attribute не є дійсним ULID.', 32 | 'ean' => 'Поле :attribute не є дійсним Європейським номером товару (EAN).', 33 | 'gtin' => 'Поле :attribute не є дійсним глобальним номером товару (GTIN).', 34 | 'postalcode' => 'Поле :attribute повинно містити дійсний поштовий індекс.', 35 | 'mimetype' => 'Значення :attribute не містить дійсний тип медіа-даних (MIME-Type).', 36 | 'austrianinsurancenumber' => 'Значення :attribute не містить дійсного австрійського номера страхування.', 37 | 'grid' => 'Значення :attribute повинно містити дійсний глобальний ідентифікатор релізу (GRID).', 38 | 'hslcolor' => 'Значення :attribute повинно містити дійсний HSL-код кольору.', 39 | 'hsvcolor' => 'Значення :attribute повинно містити дійсний HSV-код кольору.', 40 | 'latitude' => 'Поле :attribute повинно містити дійсну географічну широту.', 41 | 'longitude' => 'Поле :attribute повинно містити дійсну географічну довготу.', 42 | 'latlng' => 'Поле :attribute повинно містити дійсні географічні координати.', 43 | ]; 44 | --------------------------------------------------------------------------------