8000 [Validator] Added missing error codes and turned codes into UUIDs · symfony/symfony@cb9c069 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb9c069

Browse files
committed
[Validator] Added missing error codes and turned codes into UUIDs
1 parent cad16ac commit cb9c069

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+268
-98
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
*/
2424
class Blank extends Constraint
2525
{
26+
const NOT_BLANK_ERROR = '183ad2de-533d-4796-a439-6d3c3852b549';
27+
28+
protected static $errorNames = array(
29+
self::NOT_BLANK_ERROR => 'NOT_BLANK_ERROR',
30+
);
31+
2632
public $message = 'This value should be blank.';
2733
}

src/Symfony/Component/Validator/Constraints/BlankValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ public function validate($value, Constraint $constraint)
3636
if ($this->context instanceof ExecutionContextInterface) {
3737
$this->context->buildViolation($constraint->message)
3838
->setParameter('{{ value }}', $this->formatValue($value))
39+
->setCode(Blank::NOT_BLANK_ERROR)
3940
->addViolation();
4041
} else {
4142
$this->buildViolation($constraint->message)
4243
->setParameter('{{ value }}', $this->formatValue($value))
44+
->setCode(Blank::NOT_BLANK_ERROR)
4345
->addViolation();
4446
}
4547
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class CardScheme extends Constraint
2626
{
27-
const NOT_NUMERIC_ERROR = 1;
28-
const INVALID_FORMAT_ERROR = 2;
27+
const NOT_NUMERIC_ERROR = 'a2ad9231-e827-485f-8a1e-ef4d9a6d5c2e';
28+
const INVALID_FORMAT_ERROR = 'a8faedbf-1c2f-4695-8d22-55783be8efed';
2929

3030
protected static $errorNames = array(
3131
self::NOT_NUMERIC_ERROR => 'NOT_NUMERIC_ERROR',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424
class Choice extends Constraint
2525
{
26-
const NO_SUCH_CHOICE_ERROR = 1;
27-
const TOO_FEW_ERROR = 2;
28-
const TOO_MANY_ERROR = 3;
26+
const NO_SUCH_CHOICE_ERROR = '8e179f1b-97aa-4560-a02f-2a8b42e49df7';
27+
const TOO_FEW_ERROR = '11edd7eb-5872-4b6e-9f12-89923999fd0e';
28+
const TOO_MANY_ERROR = '9bd98e49-211c-433f-8630-fd1c2d0f08c3';
2929

3030
protected static $errorNames = array(
3131
self::NO_SUCH_CHOICE_ERROR => 'NO_SUCH_CHOICE_ERROR',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424
class Collection extends Composite
2525
{
26-
const MISSING_FIELD_ERROR = 1;
27-
const NO_SUCH_FIELD_ERROR = 2;
26+
const MISSING_FIELD_ERROR = '2fa2158c-2a7f-484b-98aa-975522539ff8';
27+
const NO_SUCH_FIELD_ERROR = '7703c766-b5d5-4cef-ace7-ae0dd82304e9';
2828

2929
protected static $errorNames = array(
3030
self::MISSING_FIELD_ERROR => 'MISSING_FIELD_ERROR',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class Count extends Constraint
2626
{
27-
const TOO_FEW_ERROR = 1;
28-
const TOO_MANY_ERROR = 2;
27+
const TOO_FEW_ERROR = 'bef8e338-6ae5-4caf-b8e2-50e7b0579e69';
28+
const TOO_MANY_ERROR = '756b1212-697c-468d-a9ad-50dd783bb169';
2929

3030
protected static $errorNames = array(
3131
self::TOO_FEW_ERROR => 'TOO_FEW_ERROR',

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
*/
2424
class Country extends Constraint
2525
{
26+
const NO_SUCH_COUNTRY_ERROR = '8f900c12-61bd-455d-9398-996cd040f7f0';
27+
28+
protected static $errorNames = array(
29+
self::NO_SUCH_COUNTRY_ERROR => 'NO_SUCH_COUNTRY_ERROR',
30+
);
31+
2632
public $message = 'This value is not a valid country.';
2733
}

src/Symfony/Component/Validator/Constraints/CountryValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ public function validate($value, Constraint $constraint)
5050
if ($this->context instanceof ExecutionContextInterface) {
5151
$this->context->buildViolation($constraint->message)
5252
->setParameter('{{ value }}', $this->formatValue($value))
53+
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
5354
->addViolation();
5455
} else {
5556
$this->buildViolation($constraint->message)
5657
->setParameter('{{ value }}', $this->formatValue($value))
58+
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
5759
->addViolation();
5860
}
5961
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
*/
2424
class Currency extends Constraint
2525
{
26+
const NO_SUCH_CURRENCY_ERROR = '69945ac1-2db4-405f-bec7-d2772f73df52';
27+
28+
protected static $errorNames = array(
29+
self::NO_SUCH_CURRENCY_ERROR => 'NO_SUCH_CURRENCY_ERROR',
30+
);
31+
2632
public $message = 'This value is not a valid currency.';
2733
}

src/Symfony/Component/Validator/Constraints/CurrencyValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ public function validate($value, Constraint $constraint)
5050
if ($this->context instanceof ExecutionContextInterface) {
5151
$this->context->buildViolation($constraint->message)
5252
->setParameter('{{ value }}', $this->formatValue($value))
53+
->setCode(Currency::NO_SUCH_CURRENCY_ERROR)
5354
->addViolation();
5455
} else {
5556
$this->buildViolation($constraint->message)
5657
->setParameter('{{ value }}', $this->formatValue($value))
58+
->setCode(Currency::NO_SUCH_CURRENCY_ERROR)
5759
->addViolation();
5860
}
5961
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424
class Date extends Constraint
2525
{
26-
const INVALID_FORMAT_ERROR = 1;
27-
const INVALID_DATE_ERROR = 2;
26+
const INVALID_FORMAT_ERROR = '69819696-02ac-4a99-9ff0-14e127c4d1bc';
27+
const INVALID_DATE_ERROR = '3c184ce5-b31d-4de7-8b76-326da7b2be93';
2828

2929
protected static $errorNames = array(
3030
self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',

src/Symfony/Component/Validator/Constraints/DateTime.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424
class DateTime extends Constraint
2525
{
26-
const INVALID_FORMAT_ERROR = 1;
27-
const INVALID_DATE_ERROR = 2;
28-
const INVALID_TIME_ERROR = 3;
26+
const INVALID_FORMAT_ERROR = '1a9da513-2640-4f84-9b6a-4d99dcddc628';
27+
const INVALID_DATE_ERROR = 'd52afa47-620d-4d99-9f08-f4d85b36e33c';
28+
const INVALID_TIME_ERROR = '5e797c9d-74f7-4098-baa3-94390c447b27';
2929

3030
protected static $errorNames = array(
3131
self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',

src/Symfony/Component/Validator/Constraints/Email.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424
class Email extends Constraint
2525
{
26-
const INVALID_FORMAT_ERROR = 1;
27-
const MX_CHECK_FAILED_ERROR = 2;
28-
const HOST_CHECK_FAILED_ERROR = 3;
26+
const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310';
27+
const MX_CHECK_FAILED_ERROR = 'bf447c1c-0266-4e10-9c6c-573df282e413';
28+
const HOST_CHECK_FAILED_ERROR = '7da53a8b-56f3-4288-bb3e-ee9ede4ef9a1';
2929

3030
protected static $errorNames = array(
3131
self::INVALID_FORMAT_ERROR => 'STRICT_CHECK_FAILED_ERROR',

src/Symfony/Component/Validator/Constraints/Expression.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
*/
2323
class Expression extends Constraint
2424
{
25+
const EXPRESSION_FAILED_ERROR 10000 = '6b3befbc-2f01-4ddf-be21-b57898905284';
26+
27+
protected static $errorNames = array(
28+
self::EXPRESSION_FAILED_ERROR => 'EXPRESSION_FAILED_ERROR',
29+
);
30+
2531
public $message = 'This value is not valid.';
2632
public $expression;
2733

src/Symfony/Component/Validator/Constraints/ExpressionValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ public function validate($value, Constraint $constraint)
8888
if ($this->context instanceof ExecutionContextInterface) {
8989
$this->context->buildViolation($constraint->message)
9090
->setParameter('{{ value }}', $this->formatValue($value))
91+
->setCode(Expression::EXPRESSION_FAILED_ERROR)
9192
->addViolation();
9293
} else {
9394
$this->buildViolation($constraint->message)
9495
->setParameter('{{ value }}', $this->formatValue($value))
96+
->setCode(Expression::EXPRESSION_FAILED_ERROR)
9597
->addViolation();
9698
}
9799
}

src/Symfony/Component/Validator/Constraints/File.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class File extends Constraint
2626
{
2727
// Check the Image constraint for clashes if adding new constants here
2828

29-
const NOT_FOUND_ERROR = 1;
30-
const NOT_READABLE_ERROR = 2;
31-
const EMPTY_ERROR = 3;
32-
const TOO_LARGE_ERROR = 4;
33-
const INVALID_MIME_TYPE_ERROR = 5;
29+
const NOT_FOUND_ERROR = 'd2a3fb6e-7ddc-4210-8fbf-2ab345ce1998';
30+
const NOT_READABLE_ERROR = 'c20c92a4-5bfa-4202-9477-28e800e0f6ff';
31+
const EMPTY_ERROR = '5d743385-9775-4aa5-8ff5-495fb1e60137';
32+
const TOO_LARGE_ERROR = 'df8637af-d466-48c6-a59d-e7126250a654';
33+
const INVALID_MIME_TYPE_ERROR = '744f00bc-4389-4c74-92de-9a43cde55534';
3434

3535
protected static $errorNames = array(
3636
self::NOT_FOUND_ERROR => 'NOT_FOUND_ERROR',

src/Symfony/Component/Validator/Constraints/Iban.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
*/
2424
class Iban extends Constraint
2525
{
26-
const TOO_SHORT_ERROR = 1;
27-
const INVALID_COUNTRY_CODE_ERROR = 2;
28-
const INVALID_CHARACTERS_ERROR = 3;
29-
const INVALID_CASE_ERROR = 4;
30-
const CHECKSUM_FAILED_ERROR = 5;
26+
const TOO_SHORT_ERROR = '88e5e319-0aeb-4979-a27e-3d9ce0c16166';
27+
const INVALID_COUNTRY_CODE_ERROR = 'de78ee2c-bd50-44e2-aec8-3d8228aeadb9';
28+
const INVALID_CHARACTERS_ERROR = '8d3d85e4-784f-4719-a5bc-d9e40d45a3a5';
29+
const INVALID_CASE_ERROR = 'f4bf62fe-03ec-42af-a53b-68e21b1e7274';
30+
const CHECKSUM_FAILED_ERROR = 'b9401321-f9bf-4dcb-83c1-f31094440795';
3131

3232
protected static $errorNames = array(
3333
self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',

src/Symfony/Component/Validator/Constraints/Image.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@
2222
*/
2323
class Image extends File
2424
{
25-
// Don't reuse values used in File
26-
27-
const SIZE_NOT_DETECTED_ERROR = 10;
28-
const TOO_WIDE_ERROR = 11;
29-
const TOO_NARROW_ERROR = 12;
30-
const TOO_HIGH_ERROR = 13;
31-
const TOO_LOW_ERROR = 14;
32-
const RATIO_TOO_BIG_ERROR = 15;
33-
const RATIO_TOO_SMALL_ERROR = 16;
34-
const SQUARE_NOT_ALLOWED_ERROR = 17;
35-
const LANDSCAPE_NOT_ALLOWED_ERROR = 18;
36-
const PORTRAIT_NOT_ALLOWED_ERROR = 19;
25+
const SIZE_NOT_DETECTED_ERROR = '6d55c3f4-e58e-4fe3-91ee-74b492199956';
26+
const TOO_WIDE_ERROR = '7f87163d-878f-47f5-99ba-a8eb723a1ab2';
27+
const TOO_NARROW_ERROR = '9afbd561-4f90-4a27-be62-1780fc43604a';
28+
const TOO_HIGH_ERROR = '7efae81c-4877-47ba-aa65-d01ccb0d4645';
29+
const TOO_LOW_ERROR = 'aef0cb6a-c07f-4894-bc08-1781420d7b4c';
30+
const RATIO_TOO_BIG_ERROR = '70cafca6-168f-41c9-8c8c-4e47a52be643';
31+
const RATIO_TOO_SMALL_ERROR = '59b8c6ef-bcf2-4ceb-afff-4642ed92f12e';
32+
const SQUARE_NOT_ALLOWED_ERROR = '5d41425b-facb-47f7-a55a-de9fbe45cb46';
33+
const LANDSCAPE_NOT_ALLOWED_ERROR = '6f895685-7cf2-4d65-b3da-9029c5581d88';
34+
const PORTRAIT_NOT_ALLOWED_ERROR = '65608156-77da-4c79-a88c-02ef6d18c782';
3735

3836
// Include the mapping from the base class
3937

src/Symfony/Component/Validator/Constraints/Ip.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class Ip extends Constraint
4646
const V6_ONLY_PUBLIC = '6_public';
4747
const ALL_ONLY_PUBLIC = 'all_public';
4848

49+
const INVALID_IP_ERROR = 'b1b427ae-9f6f-41b0-aa9b-84511fbb3c5b';
50+
4951
protected static $versions = array(
5052
self::V4,
5153
self::V6,
@@ -64,6 +66,10 @@ class Ip extends Constraint
6466
self::ALL_ONLY_PUBLIC,
6567
);
6668

69+
protected static $errorNames = array(
70+
self::INVALID_IP_ERROR => 'INVALID_IP_ERROR',
71+
);
72+
6773
public $version = self::V4;
6874

6975
public $message = 'This is not a valid IP address.';

src/Symfony/Component/Validator/Constraints/IpValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ public function validate($value, Constraint $constraint)
9999
if ($this->context instanceof ExecutionContextInterface) {
100100
$this->context->buildViolation($constraint->message)
101101
->setParameter('{{ value }}', $this->formatValue($value))
102+
->setCode(Ip::INVALID_IP_ERROR)
102103
->addViolation();
103104
} else {
104105
$this->buildViolation($constraint->message)
105106
->setParameter('{{ value }}', $this->formatValue($value))
107+
->setCode(Ip::INVALID_IP_ERROR)
106108
->addViolation();
107109
}
108110
}

src/Symfony/Component/Validator/Constraints/IsFalse.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
*/
2424
class IsFalse extends Constraint
2525
{
26+
const NOT_FALSE_ERROR = 'd53a91b0-def3-426a-83d7-269da7ab4200';
27+
28+
protected static $errorNames = array(
29+
self::NOT_FALSE_ERROR => 'NOT_FALSE_ERROR',
30+
);
31+
2632
public $message = 'This value should be false.';
2733
}

src/Symfony/Component/Validator/Constraints/IsFalseValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ public function validate($value, Constraint $constraint)
3939
if ($this->context instanceof ExecutionContextInterface) {
4040
$this->context->buildViolation($constraint->message)
4141
->setParameter('{{ value }}', $this->formatValue($value))
42+
->setCode(IsFalse::NOT_FALSE_ERROR)
4243
->addViolation();
4344
} else {
4445
$this->buildViolation($constraint->message)
4546
->setParameter('{{ value }}', $this->formatValue($value))
47+
->setCode(IsFalse::NOT_FALSE_ERROR)
4648
->addViolation();
4749
}
4850
}

src/Symfony/Component/Validator/Constraints/IsNull.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
*/
2424
class IsNull extends Constraint
2525
{
26+
const NOT_NULL_ERROR = '60d2f30b-8cfa-4372-b155-9656634de120';
27+
28+
protected static $errorNames = array(
29+
self::NOT_NULL_ERROR => 'NOT_NULL_ERROR',
30+
);
31+
2632
public $message = 'This value should be null.';
2733
}

src/Symfony/Component/Validator/Constraints/IsNullValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ public function validate($value, Constraint $constraint)
3636
if ($this->context instanceof ExecutionContextInterface) {
3737
$this->context->buildViolation($constraint->message)
3838
->setParameter('{{ value }}', $this->formatValue($value))
39+
->setCode(IsNull::NOT_NULL_ERROR)
3940
->addViolation();
4041
} else {
4142
$this->buildViolation($constraint->message)
4243
->setParameter('{{ value }}', $this->formatValue($value))
44+
->setCode(IsNull::NOT_NULL_ERROR)
4345
->addViolation();
4446
}
4547
}

src/Symfony/Component/Validator/Constraints/IsTrue.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
*/
2424
class IsTrue extends Constraint
2525
{
26+
const NOT_TRUE_ERROR = '2beabf1c-54c0-4882-a928-05249b26e23b';
27+
28+
protected static $errorNames = array(
29+
self::NOT_TRUE_ERROR => 'NOT_TRUE_ERROR',
30+
);
31+
2632
public $message = 'This value should be true.';
2733
}

src/Symfony/Component/Validator/Constraints/IsTrueValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ public function validate($value, Constraint $constraint)
4040
if ($this->context instanceof ExecutionContextInterface) {
4141
$this->context->buildViolation($constraint->message)
4242
->setParameter('{{ value }}', $this->formatValue($value))
43+
->setCode(IsTrue::NOT_TRUE_ERROR)
4344
->addViolation();
4445
} else {
4546
$this->buildViolation($constraint->message)
4647
->setParameter('{{ value }}', $this->formatValue($value))
48+
->setCode(IsTrue::NOT_TRUE_ERROR)
4749
->addViolation();
4850
}
4951
}

src/Symfony/Component/Validator/Constraints/Isbn.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
*/
2424
class Isbn extends Constraint
2525
{
26-
const TOO_SHORT_ERROR = 1;
27-
const TOO_LONG_ERROR = 2;
28-
const INVALID_CHARACTERS_ERROR = 3;
29-
const CHECKSUM_FAILED_ERROR = 4;
30-
const TYPE_NOT_RECOGNIZED_ERROR = 5;
26+
const TOO_SHORT_ERROR = '949acbb0-8ef5-43ed-a0e9-032dfd08ae45';
27+
const TOO_LONG_ERROR = '3171387d-f80a-47b3-bd6e-60598545316a';
28+
const INVALID_CHARACTERS_ERROR = '23d21cea-da99-453d-98b1-a7d916fbb339';
29+
const CHECKSUM_FAILED_ERROR = '2881c032-660f-46b6-8153-d352d9706640';
30+
const TYPE_NOT_RECOGNIZED_ERROR = 'fa54a457-f042-441f-89c4-066ee5bdd3e1';
3131

3232
protected static $errorNames = array(
3333
self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',

src/Symfony/Component/Validator/Constraints/Issn.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
*/
2323
class Issn extends Constraint
2424
{
25-
const TOO_SHORT_ERROR = 1;
26-
const TOO_LONG_ERROR = 2;
27-
const MISSING_HYPHEN_ERROR = 3;
28-
const INVALID_CHARACTERS_ERROR = 4;
29-
const INVALID_CASE_ERROR = 5;
30-
const CHECKSUM_FAILED_ERROR = 6;
25+
const TOO_SHORT_ERROR = '6a20dd3d-f463-4460-8e7b-18a1b98abbfb';
26+
const TOO_LONG_ERROR = '37cef893-5871-464e-8b12-7fb79324833c';
27+
const MISSING_HYPHEN_ERROR = '2983286f-8134-4693-957a-1ec4ef887b15';
28+
const INVALID_CHARACTERS_ERROR = 'a663d266-37c2-4ece-a914-ae891940c588';
29+
const INVALID_CASE_ERROR = '7b6dd393-7523-4a6c-b84d-72b91bba5e1a';
30+
const CHECKSUM_FAILED_ERROR = 'b0f92dbc-667c-48de-b526-ad9586d43e85';
3131

3232
protected static $errorNames = array(
3333
self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR',

0 commit comments

Comments
 (0)
0