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

Commit 4b7ceff

Browse files
authored
Merge pull request #27 from programmatordev/1.x
1.x
2 parents 79f1deb + 6efac9a commit 4b7ceff

File tree

4 files changed

+90
-28
lines changed

4 files changed

+90
-28
lines changed

docs/02-usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Returns an array with the defined set of rules.
128128

129129
```php
130130
/**
131-
* @returns RuleInterface[]
131+
* @return RuleInterface[]
132132
*/
133133
getRules(): array
134134
```

docs/03x-rules-choice.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Choice(
88
bool $multiple = false,
99
?int $minConstraint = null,
1010
?int $maxConstraint = null,
11-
string $message = 'The "{{ name }}" value is not a valid choice, "{{ value }}" given. Accepted values are: "{{ constraints }}".';
12-
string $multipleMessage = 'The "{{ name }}" value has one or more invalid choices, "{{ value }}" given. Accepted values are: "{{ constraints }}".';
13-
string $minMessage = 'The "{{ name }}" value must have at least {{ minConstraint }} choices, {{ numValues }} choices given.';
14-
string $maxMessage = 'The "{{ name }}" value must have at most {{ maxConstraint }} choices, {{ numValues }} choices given.';
11+
string $message = 'The "{{ name }}" value is not a valid choice, "{{ value }}" given. Accepted values are: "{{ constraints }}".',
12+
string $multipleMessage = 'The "{{ name }}" value has one or more invalid choices, "{{ value }}" given. Accepted values are: "{{ constraints }}".',
13+
string $minMessage = 'The "{{ name }}" value must have at least {{ minConstraint }} choices, {{ numValues }} choices given.',
14+
string $maxMessage = 'The "{{ name }}" value must have at most {{ maxConstraint }} choices, {{ numValues }} choices given.'
1515
);
1616
```
1717

src/ChainedValidatorInterface.php

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,52 @@ public function validate(mixed $value): bool;
1616

1717
// --- Rules ---
1818

19-
public function all(array $constraints, array $options = null): ChainedValidatorInterface;
19+
public function all(
20+
array $constraints,
21+
string $message = 'At "{{ key }}": {{ message }}'
22+
): ChainedValidatorInterface;
2023

21-
public function choice(array $constraints, bool $multiple = false, ?int $minConstraint = null, ?int $maxConstraint = null, array $options = []): ChainedValidatorInterface;
24+
public function choice(
25+
array $constraints,
26+
bool $multiple = false,
27+
?int $minConstraint = null,
28+
?int $maxConstraint = null,
29+
string $message = 'The "{{ name }}" value is not a valid choice, "{{ value }}" given. Accepted values are: "{{ constraints }}".',
30+
string $multipleMessage = 'The "{{ name }}" value has one or more invalid choices, "{{ value }}" given. Accepted values are: "{{ constraints }}".',
31+
string $minMessage = 'The "{{ name }}" value must have at least {{ minConstraint }} choices, {{ numValues }} choices given.',
32+
string $maxMessage = 'The "{{ name }}" value must have at most {{ maxConstraint }} choices, {{ numValues }} choices given.'
33+
): ChainedValidatorInterface;
2234

23-
public function greaterThan(mixed $constraint, array $options = []): ChainedValidatorInterface;
35+
public function greaterThan(
36+
mixed $constraint,
37+
string $message = 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.'
38+
): ChainedValidatorInterface;
2439

25-
public function greaterThanOrEqual(mixed $constraint, array $options = []): ChainedValidatorInterface;
40+
public function greaterThanOrEqual(
41+
mixed $constraint,
42+
string $message = 'The "{{ name }}" value should be greater than or equal to "{{ constraint }}", "{{ value }}" given.'
43+
): ChainedValidatorInterface;
2644

27-
public function lessThan(mixed $constraint, array $options = []): ChainedValidatorInterface;
45+
public function lessThan(
46+
mixed $constraint,
47+
string $message = 'The "{{ name }}" value should be less than "{{ constraint }}", "{{ value }}" given.'
48+
): ChainedValidatorInterface;
2849

29-
public function lessThanOrEqual(mixed $constraint, array $options = []): ChainedValidatorInterface;
50+
public function lessThanOrEqual(
51+
mixed $constraint,
52+
string $message = 'The "{{ name }}" value should be less than or equal to "{{ constraint }}", "{{ value }}" given.'
53+
): ChainedValidatorInterface;
3054

31-
public function notBlank(array $options = []): ChainedValidatorInterface;
55+
public function notBlank(
56+
?callable $normalizer = null,
57+
string $message = 'The "{{ name }}" value should not be blank, "{{ value }}" given.'
58+
): ChainedValidatorInterface;
3259

33-
public function range(mixed $minConstraint, mixed $maxConstraint, array $options = []): ChainedValidatorInterface;
60+
public function range(
61+
mixed $minConstraint,
62+
mixed $maxConstraint,
63+
string $message = 'The "{{ name }}" value should be between "{{ minConstraint }}" and "{{ maxConstraint }}", "{{ value }}" given.'
64+
): ChainedValidatorInterface;
3465

3566
public function rule(RuleInterface $constraint): ChainedValidatorInterface;
3667
}

src/StaticValidatorInterface.php

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,52 @@
66

77
interface StaticValidatorInterface
88
{
9-
public static function all(array $constraints, array $options = null): ChainedValidatorInterface;
10-
11-
public static function choice(array $constraints, bool $multiple = false, ?int $minConstraint = null, ?int $maxConstraint = null, array $options = []): ChainedValidatorInterface;
12-
13-
public static function greaterThan(mixed $constraint, array $options = []): ChainedValidatorInterface;
14-
15-
public static function greaterThanOrEqual(mixed $constraint, array $options = []): ChainedValidatorInterface;
16-
17-
public static function lessThan(mixed $constraint, array $options = []): ChainedValidatorInterface;
18-
19-
public static function lessThanOrEqual(mixed $constraint, array $options = []): ChainedValidatorInterface;
20-
21-
public static function notBlank(array $options = []): ChainedValidatorInterface;
22-
23-
public static function range(mixed $minConstraint, mixed $maxConstraint, array $options = []): ChainedValidatorInterface;
9+
public static function all(
10+
array $constraints,
11+
string $message = 'At "{{ key }}": {{ message }}'
12+
): ChainedValidatorInterface;
13+
14+
public static function choice(
15+
array $constraints,
16+
bool $multiple = false,
17+
?int $minConstraint = null,
18+
?int $maxConstraint = null,
19+
string $message = 'The "{{ name }}" value is not a valid choice, "{{ value }}" given. Accepted values are: "{{ constraints }}".',
20+
string $multipleMessage = 'The "{{ name }}" value has one or more invalid choices, "{{ value }}" given. Accepted values are: "{{ constraints }}".',
21+
string $minMessage = 'The "{{ name }}" value must have at least {{ minConstraint }} choices, {{ numValues }} choices given.',
22+
string $maxMessage = 'The "{{ name }}" value must have at most {{ maxConstraint }} choices, {{ numValues }} choices given.'
23+
): ChainedValidatorInterface;
24+
25+
public static function greaterThan(
26+
mixed $constraint,
27+
string $message = 'The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.'
28+
): ChainedValidatorInterface;
29+
30+
public static function greaterThanOrEqual(
31+
mixed $constraint,
32+
string $message = 'The "{{ name }}" value should be greater than or equal to "{{ constraint }}", "{{ value }}" given.'
33+
): ChainedValidatorInterface;
34+
35+
public static function lessThan(
36+
mixed $constraint,
37+
string $message = 'The "{{ name }}" value should be less than "{{ constraint }}", "{{ value }}" given.'
38+
): ChainedValidatorInterface;
39+
40+
public static function lessThanOrEqual(
41+
mixed $constraint,
42+
string $message = 'The "{{ name }}" value should be less than or equal to "{{ constraint }}", "{{ value }}" given.'
43+
): ChainedValidatorInterface;
44+
45+
public static function notBlank(
46+
?callable $normalizer = null,
47+
string $message = 'The "{{ name }}" value should not be blank, "{{ value }}" given.'
48+
): ChainedValidatorInterface;
49+
50+
public static function range(
51+
mixed $minConstraint,
52+
mixed $maxConstraint,
53+
string $message = 'The "{{ name }}" value should be between "{{ minConstraint }}" and "{{ maxConstraint }}", "{{ value }}" given.'
54+
): ChainedValidatorInterface;
2455

2556
public static function rule(RuleInterface $constraint): ChainedValidatorInterface;
2657
}

0 commit comments

Comments
 (0)