Skip to content

Commit fee4542

Browse files
author
Augustin Pasquini
committed
Allowing custom message on rna constraint with explicit constructor
1 parent 72ef63d commit fee4542

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ parameters:
525525
count: 1
526526
path: src/Validator/Constraints/FloatScale.php
527527

528+
-
529+
message: "#^Method AssoConnect\\\\ValidatorBundle\\\\Validator\\\\Constraints\\\\FrenchRna\\:\\:__construct\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
530+
count: 1
531+
path: src/Validator/Constraints/FrenchRna.php
532+
528533
-
529534
message: "#^Public property `message` not marked as readonly\\.$#"
530535
count: 1

src/Validator/Constraints/FrenchRna.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ class FrenchRna extends Constraint
1515
public const INVALID_FORMAT_ERROR = 'd125c480-3efd-42dd-9a59-6058fddd4fe4';
1616

1717
public string $message = 'The value {{ value }} is not a valid RNA identifier.';
18+
19+
public function __construct(
20+
?array $options = null,
21+
?string $message = null,
22+
?array $groups = null,
23+
mixed $payload = null,
24+
) {
25+
parent::__construct($options, $groups, $payload);
26+
27+
$this->message = $message ?? $this->message;
28+
}
1829
}

0 commit comments

Comments
 (0)