File: D:/HostingSpaces/debout/debout.nl/vendor/komma/kms/src/Globalization/Rules/ValidCountryIso3.php
<?php declare(strict_types=1);
namespace Komma\KMS\Globalization\Rules;
use Komma\KMS\Globalization\RegionInfo;
use Illuminate\Contracts\Validation\Rule;
/**
* Class ValidCountryNativeName
*
* Validates a countries three letter iso region name. E.g NLD for Netherlands for examples
*/
class ValidCountryIso3 implements Rule
{
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$regionInfos = RegionInfo::getNeutralCultures()->filter(function(RegionInfo $regionInfo) use ($value) {
return $regionInfo->getThreeLetterISORegionName() === $value;
});
return $regionInfos->count() == 1;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return __('globalisation.validation.country');
}
}