Skip to content

Country

Pieter Hordijk edited this page Dec 30, 2018 · 1 revision

TOC

Alpha2Code

Validates the input (string) to be a valid ISO alpha 2 country code.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Country\Alpha2Code;

(new Alpha2Code())->validate('NL');

Failure reasons

  • Type.String when the validated value is not a string
  • Country.Alpha2Code when the validated value is not a valid alpha 2 country code

Alpha3Code

Validates the input (string) to be a valid ISO alpha 3 country code.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Country\Alpha3Code;

(new Alpha3Code())->validate('NLD');

Failure reasons

  • Type.String when the validated value is not a string
  • Country.Alpha3Code when the validated value is not a valid alpha 3 country code

NumericCode

Validates the input (string) to be a valid ISO numeric country code.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Country\NumericCode;

(new NumericCode())->validate('894');

Failure reasons

  • Type.String when the validated value is not a string
  • Country.NumericCode when the validated value is not a valid numeric country code
Clone this wiki locally