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

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,

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

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

1616
/**
17+
* Validates a collection with constraints defined for specific keys.
18+
*
1719
* @Annotation
1820
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1921
*
@@ -41,6 +43,15 @@ class Collection extends Composite
4143
public $extraFieldsMessage = 'This field was not expected.';
4244
public $missingFieldsMessage = 'This field is missing.';
4345

46+
/**
47+
* @param mixed|null $fields An associative array defining keys in the collection and their constraints
48+
* @param array|null $groups An array of validation groups
49+
* @param mixed|null $payload Domain-specific data attached to a constraint
50+
* @param bool|null $allowExtraFields Whether to allow additional keys not declared in the configured fields
51+
* @param bool|null $allowMissingFields Whether to allow the collection to lack some fields declared in the configured fields
52+
* @param string|null $extraFieldsMessage The message if extra fields are not allowed and the data contains extra fields
53+
* @param string|null $missingFieldsMessage The message if missing fields are not allowed and the data lacks some fields
54+
*/
4455
public function __construct(mixed $fields = null, array $groups = null, mixed $payload = null, bool $allowExtraFields = null, bool $allowMissingFields = null, string $extraFieldsMessage = null, string $missingFieldsMessage = null)
4556
{
4657
// no known options set? $fields is the fields array

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

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

1717
/**
18+
* Validates a collection's element count.
19+
*
1820
* @Annotation
1921
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2022
*
@@ -48,6 +50,19 @@ class Count extends Constraint
4850
public $max;
4951
public $divisibleBy;
5052

53+
/**
54+
* @param int|array|null $exactly The exact expected number of elements
55+
* @param int|null $min Minimum expected number of elements
56+
* @param int|null $max Maximum expected number of elements
57+
* @param int|null $divisibleBy The number the collection count should be divisible by
58+
* @param string|null $exactMessage Message if the collection count should be exactly
59+
* @param string|null $minMessage Message if the collection has fewer values than the min
60+
* @param string|null $maxMessage Message if the collection has more values than the max
61+
* @param string|null $divisibleByMessage Message if the count is not divisible by the divisibleBy value
62+
* @param array|null $groups An array of validation groups
63+
* @param mixed|null $payload Domain-specific data attached to a constraint
64+
* @param array $options The options (as associative array) or the value for the default option (any other type)
65+
*/
5166
public function __construct(
5267
int|array $exactly = null,
5368
int $min = null,

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

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

1818
/**
19+
* Validates a value is a valid ISO 3166-1 alpha-2 country code.
20+
*
21+
* @see https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
22+
*
1923
* @Annotation
2024
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2125
*
@@ -38,6 +42,15 @@ class Country extends Constraint
3842
public $message = 'This value is not a valid country.';
3943
public $alpha3 = false;
4044

45+
/**
46+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
47+
* @param string|null $message The message if the validation fails
48+
* @param bool|null $alpha3 Whether to check for alpha-3 codes instead of alpha-2
49+
* @param array|null $groups An array of validation groups
50+
* @param mixed|null $payload Domain-specific data attached to a constraint
51+
*
52+
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3#Current_codes
53+
*/
4154
public function __construct(
4255
array $options = null,
4356
string $message = null,

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

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

1717
/**
18+
* Validates that a value is a valid CSS color.
19+
*
1820
* @Annotation
1921
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2022
*
@@ -68,7 +70,12 @@ class CssColor extends Constraint
6870
public $formats;
6971

7072
/**
71-
* @param array|string $formats The types of CSS colors allowed (e.g. hexadecimal only, RGB and HSL only, etc.).
73+
* @param array|string $formats The types of CSS colors allowed (e.g. hexadecimal only, RGB and HSL only, etc.)
74+
* @param string|null $message The message if the validation fails
75+
* @param array|null $groups An array of validation groups
76+
* @param mixed|null $payload Domain-specific data attached to a constraint
77+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
78+
*
7279
*/
7380
public function __construct($formats = [], string $message = null, array $groups = null, $payload = null, array $options = null)
7481
{

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

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

1818
/**
19+
* Validates that a value s a valid 3-letter ISO 4217 currency name.
20+
*
21+
* @see https://en.wikipedia.org/wiki/ISO_4217
22+
*
1923
* @Annotation
2024
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2125
*
@@ -38,6 +42,12 @@ class Currency extends Constraint
3842

3943
public $message = 'This value is not a valid currency.';
4044

45+
/**
46+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
47+
* @param string|null $message The message if the validation fails
48+
* @param array|null $groups An array of validation groups
49+
* @param mixed|null $payload Domain-specific data attached to a constraint
50+
*/
4151
public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null)
4252
{
4353
if (!class_exists(Currencies::class)) {

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

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

1616
/**
17+
* Validates that a value is a valid date, i.e. its string representation follows the Y-m-d format.
18+
*
19+
* @see https://www.php.net/manual/en/datetime.format.php
20+
*
1721
* @Annotation
1822
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1923
*
@@ -37,6 +41,12 @@ class Date extends Constraint
3741

3842
public $message = 'This value is not a valid date.';
3943

44+
/**
45+
* @param array|null $options The options (as associative array) or the value for the default option (any other type)
46+
* @param string|null $message The message if the validation fails
47+
* @param array|null $groups An array of validation groups
48+
* @param mixed|null $payload Domain-specific data attached to a constraint
49+
*/
4050
public function __construct(array $options = null, string $message = null, array $groups = null, mixed $payload = null)
4151
{
4252
parent::__construct($options, $groups, $payload);

0 commit comments

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