Skip to content

Commit 58f8b30

Browse files
authored
feature #1590 [make:validator] drop annotation support in constraint
1 parent a3b7f14 commit 58f8b30

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/Resources/skeleton/validator/Constraint.tpl.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
use Symfony\Component\Validator\Constraint;
66

7-
/**
8-
* @Annotation
9-
*
10-
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
11-
*/
127
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
138
class <?= $class_name ?> extends Constraint
149
{
15-
/*
16-
* Any public properties become valid options for the annotation.
17-
* Then, use these in your validator class.
18-
*/
19-
public string $message = 'The value "{{ value }}" is not valid.';
10+
public string $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.';
11+
12+
// You can use #[HasNamedArguments] to make some constraint options required.
13+
// All configurable options must be passed to the constructor.
14+
public function __construct(
15+
public string $mode = 'strict',
16+
?array $groups = null,
17+
mixed $payload = null
18+
) {
19+
parent::__construct([], $groups, $payload);
20+
}
2021
}

0 commit comments

Comments
 (0)