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

Commit 720af0a

Browse files
authored
Merge pull request #32 from programmatordev/YAPV-44-create-country-rule
Create Country rule
2 parents 3e8bd8b + 6aef764 commit 720af0a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/03-rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
## Choice Rules
2222

2323
- [Choice](03x-rules-choice.md)
24+
- [Country](03x-rules-country.md)
2425

2526
## Other Rules
2627

src/ChainedValidatorInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public function choice(
3232
string $maxMessage = 'The "{{ name }}" value must have at most {{ maxConstraint }} choices, {{ numValues }} choices given.'
3333
): ChainedValidatorInterface;
3434

35+
public function country(
36+
string $code = 'alpha-2',
37+
string $message = 'The "{{ name }}" value is not a valid country code, "{{ value }}" given.'
38+
): ChainedValidatorInterface;
39+
3540
public function greaterThan(
3641
mixed $constraint,
3742
string $message = 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.'

src/StaticValidatorInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public static function choice(
2222
string $maxMessage = 'The "{{ name }}" value must have at most {{ maxConstraint }} choices, {{ numValues }} choices given.'
2323
): ChainedValidatorInterface;
2424

25+
public static function country(
26+
string $code = 'alpha-2',
27+
string $message = 'The "{{ name }}" value is not a valid country code, "{{ value }}" given.'
28+
): ChainedValidatorInterface;
29+
2530
public static function greaterThan(
2631
mixed $constraint,
2732
string $message = 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.'

0 commit comments

Comments
 (0)