Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Latest commit

 

History

History
58 lines (38 loc) · 1.27 KB

03-rules_language.md

File metadata and controls

58 lines (38 loc) · 1.27 KB

Language

Validates that a value is a valid language code.

Language(
    string $code = 'alpha-2',
    ?string $message = null
);

Basic Usage

// 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.

Options

code

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 code
  • alpha-3: three-letter code

message

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

Changelog

  • 1.1.0 Created