Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6faddcd

Browse filesBrowse files
committed
[Validator] Add PHPDoc to validator constraints
1 parent 5f77c3f commit 6faddcd
Copy full SHA for 6faddcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

70 files changed

+639
-10
lines changed

‎src/Symfony/Component/Validator/Attribute/HasNamedArguments.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Attribute/HasNamedArguments.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\Validator\Attribute;
1313

14+
/**
15+
* Hint the loader that some constraint options are required.
16+
*/
1417
#[\Attribute(\Attribute::TARGET_METHOD)]
1518
final class HasNamedArguments
1619
{

‎src/Symfony/Component/Validator/Constraints/All.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/All.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
/**
15+
* When applied to an array (or Traversable object), this constraint allows you to apply
16+
* a collection of constraints to each element of the array.
17+
*
1518
* @Annotation
1619
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1720
*
@@ -22,6 +25,11 @@ class All extends Composite
2225
{
2326
public $constraints = [];
2427

28+
/**
29+
* @param mixed|null $constraints An array of validation constraints
30+
* @param array|null $groups An array of validation groups
31+
* @param mixed|null $payload Domain-specific data attached to a constraint
32+
*/
2533
public function __construct(mixed $constraints = null, array $groups = null, mixed $payload = null)
2634
{
2735
parent::__construct($constraints ?? [], $groups, $payload);

‎src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
/**
15+
* Checks that at least one of the given constraint is satisfied.
16+
*
1517
* @Annotation
1618
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1719
*
@@ -36,6 +38,14 @@ class AtLeastOneOf extends Composite
3638
public $messageCollection = 'Each element of this collection should satisfy its own set of constraints.';
3739
public $includeInternalMessages = true;
3840

41+
/**
42+
* @param mixed|null $constraints An array of validation constraints
43+
* @param array|null $groups An array of validation groups
44+
* @param mixed|null $payload Domain-specific data attached to a constraint
45+
* @param string|null $message Intro of the failure message that will be followed by the failed constraint(s) message(s)
46+
* @param string|null $messageCollection Failure message for All and Collection inner constraints
47+
* @param bool|null $includeInternalMessages Whether to include inner constraint messages
48+
*/
3949
public function __construct(mixed $constraints = null, array $groups = null, mixed $payload = null, string $message = null, string $messageCollection = null, bool $includeInternalMessages = null)
4050
{
4151
parent::__construct($constraints ?? [], $groups, $payload);

‎src/Symfony/Component/Validator/Constraints/Bic.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Bic.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
use Symfony\Component\Validator\Exception\LogicException;
1919

2020
/**
21+
* Ensure that the value is valid against the BIC format.
22+
*
23+
* @see https://en.wikipedia.org/wiki/ISO_9362
24+
*
2125
* @Annotation
2226
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2327
*
@@ -51,6 +55,15 @@ class Bic extends Constraint
5155
public $iban;
5256
public $ibanPropertyPath;
5357

58+
/**
59+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
60+
* @param string|null $message The message if the validation fails
61+
* @param string|null $iban An IBAN value to validate that its country code is the same as the BIC's one
62+
* @param string|null $ibanPropertyPath Property path to the IBAN value when validating objects
63+
* @param string|null $ibanMessage Default message when the combined BIC/IBAN check does not pass
64+
* @param array|null $groups An array of validation groups
65+
* @param mixed|null $payload Domain-specific data attached to a constraint
66+
*/
5467
public function __construct(array $options = null, string $message = null, string $iban = null, string $ibanPropertyPath = null, string $ibanMessage = null, array $groups = null, mixed $payload = null)
5568
{
5669
if (!class_exists(Countries::class)) {

‎src/Symfony/Component/Validator/Constraints/Blank.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Blank.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Validator\Constraint;
1515

1616
/**
17+
* Validate that a value is blank, i.e. an empty string or null.
18+
*
1719
* @Annotation
1820
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1921
*
@@ -35,6 +37,12 @@ class Blank extends Constraint
3537

3638
public $message = 'This value should be blank.';
3739

40+
/**
41+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
42+
* @param string|null $message The message if the validation fails
43+
* @param array|null $groups An array of validation groups
44+
* @param mixed|null $payload Domain-specific data attached to a constraint
45+
*/
3846
public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null)
3947
{
4048
parent::__construct($options ?? [], $groups, $payload);

‎src/Symfony/Component/Validator/Constraints/Callback.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Callback.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Validator\Constraint;
1515

1616
/**
17+
* Define custom validation rules through arbitrary callback methods.
18+
*
1719
* @Annotation
1820
* @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})
1921
*
@@ -27,6 +29,12 @@ class Callback extends Constraint
2729
*/
2830
public $callback;
2931

32+
/**
33+
* @param array|string|callable|null $callback Callback(s) definition(s)
34+
* @param array|null $groups An array of validation groups
35+
* @param mixed|null $payload Domain-specific data attached to a constraint
36+
* @param array $options The options (as associative array) or the value for the default option (any other type)
37+
*/
3038
public function __construct(array|string|callable $callback = null, array $groups = null, mixed $payload = null, array $options = [])
3139
{
3240
// Invocation through annotations with an array parameter only

‎src/Symfony/Component/Validator/Constraints/CardScheme.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/CardScheme.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515

1616
/**
17-
* Metadata for the CardSchemeValidator.
17+
* Validates a credit card number for a given credit card company.
1818
*
1919
* @Annotation
2020
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
@@ -54,6 +54,13 @@ class CardScheme extends Constraint
5454
public $message = 'Unsupported card type or invalid card number.';
5555
public $schemes;
5656

57+
/**
58+
* @param array|string|null $schemes Name(s) of the number scheme used to validate the credit card number
59+
* @param string|null $message The message if the validation fails
60+
* @param array|null $groups An array of validation groups
61+
* @param mixed|null $payload Domain-specific data attached to a constraint
62+
* @param array $options The options (as associative array) or the value for the default option (any other type)
63+
*/
5764
public function __construct(array|string|null $schemes, string $message = null, array $groups = null, mixed $payload = null, array $options = [])
5865
{
5966
if (\is_array($schemes) && \is_string(key($schemes))) {

‎src/Symfony/Component/Validator/Constraints/Cascade.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Cascade.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1616

1717
/**
18+
* Validates a whole class, including nested objects in properties.
19+
*
1820
* @Annotation
1921
* @Target({"CLASS"})
2022
*
@@ -25,6 +27,10 @@ class Cascade extends Constraint
2527
{
2628
public array $exclude = [];
2729

30+
/**
31+
* @param array|string|null $exclude Properties excluded from validation
32+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
33+
*/
2834
public function __construct(array|string $exclude = null, array $options = null)
2935
{
3036
if (\is_array($exclude) && !array_is_list($exclude)) {

‎src/Symfony/Component/Validator/Constraints/Choice.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Choice.php
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Validator\Constraint;
1515

1616
/**
17+
* Validates that a value is one of a given set of valid choices.
18+
*
1719
* @Annotation
1820
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1921
*
@@ -55,6 +57,22 @@ public function getDefaultOption(): ?string
5557
return 'choices';
5658
}
5759

60+
/**
61+
* @param string|array $options The options (as associative array) or the value for the default option (any other type)
62+
* @param array|null $choices An array of choices
63+
* @param callable|string|null $callback Callback method to use instead of the choice option to get the choices
64+
* @param bool|null $multiple Whether to expect the value to be an array of valid choices
65+
* @param bool|null $strict This option defaults to <pre>true</pre> and should not be used
66+
* @param int|null $min Minimum of valid choices if multiple values are expected
67+
* @param int|null $max Maximum of valid choices if multiple values are expected
68+
* @param string|null $message The message if the validation fails
69+
* @param string|null $multipleMessage Message if some of the choices are not valid
70+
* @param string|null $minMessage Message if there are too few choices
71+
* @param string|null $maxMessage Message if there are too many choices
72+
* @param array|null $groups An array of validation groups
73+
* @param mixed|null $payload Domain-specific data attached to a constraint
74+
* @param bool|null $match Validate values that are not part of given choices
75+
*/
5876
public function __construct(
5977
string|array $options = [],
6078
array $choices = null,

‎src/Symfony/Component/Validator/Constraints/Cidr.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Cidr.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/**
1818
* Validates that a value is a valid CIDR notation.
1919
*
20+
* @see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
21+
*
2022
* @Annotation
2123
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2224
*
@@ -55,6 +57,15 @@ class Cidr extends Constraint
5557

5658
public $netmaskMax;
5759

60+
/**
61+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
62+
* @param string|null $version The CIDR version to validate (4, 6 or all)
63+
* @param int|null $netmaskMin The lowest valid for a valid netmask
64+
* @param int|null $netmaskMax The biggest valid for a valid netmask
65+
* @param string|null $message The message if the validation fails
66+
* @param array|null $groups An array of validation groups
67+
* @param mixed|null $payload Domain-specific data attached to a constraint
68+
*/
5869
public function __construct(
5970
array $options = null,
6071
string $version = null,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.