Validates that a value is a valid language code.
Language(
string $code = 'alpha-2',
?string $message = null
);
// default alpha-2 code
Validator::language()->validate('pt'); // true
// alpha-3 code
Validator::language(code: 'alpha-3')->validate('por'); // true
Note
An UnexpectedValueException
will be thrown when the code
value is not a valid option.
Note
An UnexpectedValueException
will be thrown when the input value is not a string
.
type: string
default: alpha-2
Set code type to validate the language. Check the official language codes list for more information.
Available options:
alpha-2
: two-letter codealpha-3
: three-letter code
type: ?string
default: The {{ name }} value is not a valid language.
Message that will be shown if the input value is not a valid language code.
The following parameters are available:
Parameter | Description |
---|---|
{{ value }} |
The current invalid value |
{{ name }} |
Name of the invalid value |
{{ code }} |
Selected code type |
1.1.0
Created