Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,42 @@ The currency code has two different formats `ALPHA` or `NUMERIC`. Select the for

If `strict` is `true`, the code must be passed in uppercase. Otherwise, the case doesn't matter.

### Language Tag (BCP 47)

The field under validation must be a valid IETF language tag according to BCP 47 standard.

public Intervention\Validation\Rules\LanguageTag::__construct(string $delimiter = '-', bool $allowScript = false, bool $allowRegion = true, bool $allowVariants = false, bool $allowExtensions = false, bool $allowPrivateUse = false, bool $strict = true)

#### Parameters

**delimiter**

Define the delimiter used for validation. Default `-`.

**allowScript**

Specify whether the script subtag is allowed during validation. Default `false.`

**allowRegion**

Specify whether the region subtag is allowed during validation. Default `true.`

**allowVariants**

Specify whether variant subtags are allowed during validation. Default `false.`

**allowExtensions**

Specify whether extension subtags are allowed during validation. Default `false.`

**allowPrivateUse**

Specify whether private use subtags are allowed during validation. Default `false.`

**strict**

If `strict` is `true`, the subtags must be in the correct case. Otherwise, the case doesn't matter. Default `true`.

## Development & Testing

With this package comes a Docker image to build a test suite container. To
Expand Down
62 changes: 4 additions & 58 deletions src/Rules/CountryCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,17 @@
namespace Intervention\Validation\Rules;

use Intervention\Validation\AbstractRule;
use Intervention\Validation\Traits\HasCountryCodeValues;
use InvalidArgumentException;

class CountryCode extends AbstractRule
{
use HasCountryCodeValues;

public const ALPHA2 = 'alpha2';
public const ALPHA3 = 'alpha3';
public const NUMERIC = 'numeric';

private const VALUES = [
self::ALPHA2 => [
'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB',
'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY',
'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX',
'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK',
'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS',
'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR',
'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA',
'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK',
'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE',
'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM',
'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG',
'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF',
'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY',
'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW',
],
self::ALPHA3 => [
'AFG', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE',
'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT',
'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'CPV', 'KHM', 'CMR', 'CAN', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN',
'CXR', 'CCK', 'COL', 'COM', 'COD', 'COG', 'COK', 'CRI', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'CIV', 'DNK',
'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'SWZ', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN',
'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM',
'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN',
'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT',
'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MDG', 'MWI', 'MYS', 'MDV',
'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR',
'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MKD', 'MNP',
'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT',
'ROU', 'RUS', 'RWA', 'REU', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU',
'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA',
'SDN', 'SUR', 'SJM', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO',
'TUN', 'TKM', 'TCA', 'TUV', 'TUR', 'UGA', 'UKR', 'ARE', 'GBR', 'UMI', 'USA', 'URY', 'UZB', 'VUT', 'VEN',
'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE', 'ALA',
],
self::NUMERIC => [
'004', '008', '010', '012', '016', '020', '024', '028', '031', '032', '036', '040', '044', '048', '050',
'051', '052', '056', '060', '072', '074', '076', '084', '086', '090', '092', '096', '100', '104', '108',
'112', '116', '120', '124', '132', '136', '140', '144', '148', '152', '156', '158', '162', '166', '170',
'174', '175', '178', '180', '184', '188', '191', '192', '196', '203', '204', '208', '212', '214', '218',
'222', '226', '231', '232', '233', '234', '238', '239', '242', '246', '248', '250', '254', '258', '260',
'262', '266', '268', '270', '275', '276', '288', '292', '296', '300', '304', '308', '312', '316', '320',
'324', '328', '332', '334', '336', '340', '344', '348', '352', '356', '360', '364', '368', '372', '376',
'380', '384', '388', '392', '398', '400', '404', '408', '410', '414', '417', '418', '422', '426', '428',
'430', '434', '438', '440', '442', '446', '450', '454', '458', '462', '466', '470', '474', '478', '480',
'484', '492', '496', '498', '499', '500', '504', '508', '512', '516', '520', '524', '528', '531', '533',
'534', '535', '540', '548', '554', '558', '562', '566', '570', '574', '578', '580', '581', '583', '584',
'585', '586', '591', '598', '600', '604', '608', '612', '616', '620', '624', '626', '630', '634', '638',
'642', '643', '646', '652', '654', '659', '660', '662', '663', '666', '670', '674', '678', '682', '686',
'688', '690', '694', '702', '703', '704', '705', '706', '710', '716', '724', '728', '729', '732', '740',
'744', '748', '752', '756', '760', '762', '764', '768', '772', '776', '780', '784', '788', '792', '795',
'796', '798', '800', '804', '807', '818', '826', '831', '832', '833', '834', '840', '850', '854', '858',
'860', '862', '876', '882', '887', '894', '064', '068', '070',
],
];

/**
* @throws InvalidArgumentException
*/
Expand All @@ -93,6 +39,6 @@ public function isValid(mixed $value): bool
$value = strtoupper($value);
}

return in_array($value, self::VALUES[$this->format], strict: true);
return in_array($value, self::$countryCodeValues[$this->format], strict: true);
}
}
17 changes: 3 additions & 14 deletions src/Rules/LanguageCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,11 @@
namespace Intervention\Validation\Rules;

use Intervention\Validation\AbstractRule;
use Intervention\Validation\Traits\HasLanguageCodeValues;

class LanguageCode extends AbstractRule
{
private const VALUES = [
'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm',
'bn', 'bo', 'br', 'bs', 'ca', 'ce', 'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee',
'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'gu',
'gv', 'ha', 'he', 'hi', 'ho', 'hr', 'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is',
'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw',
'ky', 'la', 'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms',
'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os',
'pa', 'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk',
'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl',
'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi',
'yo', 'za', 'zh', 'zu',
];
use HasLanguageCodeValues;

public function __construct(protected bool $strict = true)
{
Expand All @@ -40,6 +29,6 @@ public function isValid(mixed $value): bool
$value = strtolower($value);
}

return in_array($value, self::VALUES, strict: true);
return in_array($value, self::$languageCodeValues, strict: true);
}
}
100 changes: 100 additions & 0 deletions src/Rules/LanguageTag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

declare(strict_types=1);

namespace Intervention\Validation\Rules;

use Intervention\Validation\AbstractRule;
use Intervention\Validation\Traits\HasCountryCodeValues;
use Intervention\Validation\Traits\HasLanguageCodeValues;

class LanguageTag extends AbstractRule
{
use HasLanguageCodeValues;
use HasCountryCodeValues;

public function __construct(
protected string $delimiter = '-',
protected bool $allowScript = false,
protected bool $allowRegion = true,
protected bool $allowVariants = false,
protected bool $allowExtensions = false,
protected bool $allowPrivateUse = false,
protected bool $strict = true,
) {
//
}

/**
* {@inheritdoc}
*
* @see Rule::isValid()
*/
public function isValid(mixed $value): bool
{
$result = preg_match($this->pattern(), strval($value), $matches);

if ($result !== 1) {
return false;
}

$language = $matches['language'] ?? null;
$region = $matches['region'] ?? null;

$language = $language === '' ? null : $language;
$region = $region === '' ? null : $region;

if ($this->strict === false) {
$language = $language === null ? $language : strtolower($language);
$region = $region === null ? $region : strtoupper($region);
}

if (
$this->allowRegion === true &&
$region !== null &&
!in_array($region, self::$countryCodeValues['alpha2'], strict: true)
) {
return false;
}

return in_array($language, self::$languageCodeValues, strict: true);
}

/**
* Build regex pattern according to parameters.
*/
private function pattern(): string
{
$pattern = "/^";
$pattern .= "(?P<language>[a-z]{2})";

if ($this->allowScript === true) {
$pattern .= "(?:" . $this->delimiter . "(?<script>[A-Z][a-z]{3}))?";
}

if ($this->allowRegion === true) {
$pattern .= "(?:" . $this->delimiter . "(?<region>[A-Z]{2}))?";
}

if ($this->allowVariants === true) {
$pattern .= "(?:" . $this->delimiter . "(?<variants>[A-Za-z0-9]{5,8}|\d[A-Za-z0-9]{3}))*";
}

if ($this->allowExtensions === true) {
$pattern .= "(?:" . $this->delimiter . "(?<extensions>(?:[0-9A-WY-Za-wy-z])" .
"(?:" . $this->delimiter . "[A-Za-z0-9]{2,8})+))?";
}

if ($this->allowPrivateUse === true) {
$pattern .= "(?:" . $this->delimiter . "x(?<privateuse>(?:" . $this->delimiter . "[A-Za-z0-9]{1,8})+))?";
}

$pattern .= "$/";

if ($this->strict === false) {
$pattern .= "i";
}

return $pattern;
}
}
68 changes: 68 additions & 0 deletions src/Traits/HasCountryCodeValues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

namespace Intervention\Validation\Traits;

trait HasCountryCodeValues
{
/**
* @var array<array<string>>
*/
protected static array $countryCodeValues = [
'alpha2' => [
'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB',
'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY',
'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX',
'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK',
'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS',
'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR',
'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA',
'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK',
'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE',
'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM',
'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG',
'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF',
'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY',
'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW',
],
'alpha3' => [
'AFG', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE',
'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT',
'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'CPV', 'KHM', 'CMR', 'CAN', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN',
'CXR', 'CCK', 'COL', 'COM', 'COD', 'COG', 'COK', 'CRI', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'CIV', 'DNK',
'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'SWZ', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN',
'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM',
'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN',
'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT',
'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MDG', 'MWI', 'MYS', 'MDV',
'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR',
'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MKD', 'MNP',
'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT',
'ROU', 'RUS', 'RWA', 'REU', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU',
'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA',
'SDN', 'SUR', 'SJM', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO',
'TUN', 'TKM', 'TCA', 'TUV', 'TUR', 'UGA', 'UKR', 'ARE', 'GBR', 'UMI', 'USA', 'URY', 'UZB', 'VUT', 'VEN',
'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE', 'ALA',
],
'numeric' => [
'004', '008', '010', '012', '016', '020', '024', '028', '031', '032', '036', '040', '044', '048', '050',
'051', '052', '056', '060', '072', '074', '076', '084', '086', '090', '092', '096', '100', '104', '108',
'112', '116', '120', '124', '132', '136', '140', '144', '148', '152', '156', '158', '162', '166', '170',
'174', '175', '178', '180', '184', '188', '191', '192', '196', '203', '204', '208', '212', '214', '218',
'222', '226', '231', '232', '233', '234', '238', '239', '242', '246', '248', '250', '254', '258', '260',
'262', '266', '268', '270', '275', '276', '288', '292', '296', '300', '304', '308', '312', '316', '320',
'324', '328', '332', '334', '336', '340', '344', '348', '352', '356', '360', '364', '368', '372', '376',
'380', '384', '388', '392', '398', '400', '404', '408', '410', '414', '417', '418', '422', '426', '428',
'430', '434', '438', '440', '442', '446', '450', '454', '458', '462', '466', '470', '474', '478', '480',
'484', '492', '496', '498', '499', '500', '504', '508', '512', '516', '520', '524', '528', '531', '533',
'534', '535', '540', '548', '554', '558', '562', '566', '570', '574', '578', '580', '581', '583', '584',
'585', '586', '591', '598', '600', '604', '608', '612', '616', '620', '624', '626', '630', '634', '638',
'642', '643', '646', '652', '654', '659', '660', '662', '663', '666', '670', '674', '678', '682', '686',
'688', '690', '694', '702', '703', '704', '705', '706', '710', '716', '724', '728', '729', '732', '740',
'744', '748', '752', '756', '760', '762', '764', '768', '772', '776', '780', '784', '788', '792', '795',
'796', '798', '800', '804', '807', '818', '826', '831', '832', '833', '834', '840', '850', '854', '858',
'860', '862', '876', '882', '887', '894', '064', '068', '070',
],
];
}
25 changes: 25 additions & 0 deletions src/Traits/HasLanguageCodeValues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Intervention\Validation\Traits;

trait HasLanguageCodeValues
{
/**
* @var array<string>
*/
protected static array $languageCodeValues = [
'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az', 'ba', 'be', 'bg', 'bh', 'bi', 'bm',
'bn', 'bo', 'br', 'bs', 'ca', 'ce', 'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee',
'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr', 'fy', 'ga', 'gd', 'gl', 'gn', 'gu',
'gv', 'ha', 'he', 'hi', 'ho', 'hr', 'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is',
'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw',
'ky', 'la', 'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms',
'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os',
'pa', 'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk',
'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl',
'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi',
'yo', 'za', 'zh', 'zu',
];
}
1 change: 1 addition & 0 deletions src/lang/ar/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
'countrycode' => 'يجب أن يكون :attribute رمز بلد صالحًا.',
'languagecode' => 'يجب أن يكون :attribute رمز لغة صالحًا.',
'currencycode' => 'يجب أن يكون :attribute رمز عملة صالحًا.',
'languagetag' => 'يجب أن يكون :attribute علامة لغة صالحة.',
];
Loading