@@ -111,10 +111,10 @@ One way to accomplish this is with the Expression constraint:
111
111
{
112
112
public static function loadValidatorMetadata(ClassMetadata $metadata): void
113
113
{
114
- $metadata->addConstraint(new Assert\Expression([
115
- ' expression' => 'this.getCategory() in ["php", "symfony"] or !this.isTechnicalPost()',
116
- ' message' => 'If this is a tech post, the category should be either php or symfony!',
117
- ] ));
114
+ $metadata->addConstraint(new Assert\Expression(
115
+ expression: 'this.getCategory() in ["php", "symfony"] or !this.isTechnicalPost()',
116
+ message: 'If this is a tech post, the category should be either php or symfony!',
117
+ ));
118
118
}
119
119
120
120
// ...
@@ -200,10 +200,10 @@ assert that the expression must return ``true`` for validation to fail.
200
200
{
201
201
public static function loadValidatorMetadata(ClassMetadata $metadata): void
202
202
{
203
- $metadata->addPropertyConstraint('isTechnicalPost', new Assert\Expression([
204
- ' expression' => 'this.getCategory() in ["php", "symfony"] or value == false',
205
- ' message' => 'If this is a tech post, the category should be either php or symfony!',
206
- ] ));
203
+ $metadata->addPropertyConstraint('isTechnicalPost', new Assert\Expression(
204
+ expression: 'this.getCategory() in ["php", "symfony"] or value == false',
205
+ message: 'If this is a tech post, the category should be either php or symfony!',
206
+ ));
207
207
}
208
208
209
209
// ...
@@ -343,10 +343,10 @@ type (numeric, boolean, strings, null, etc.)
343
343
{
344
344
public static function loadValidatorMetadata(ClassMetadata $metadata): void
345
345
{
346
- $metadata->addPropertyConstraint('metric', new Assert\Expression([
347
- ' expression' => 'value + error_margin < threshold',
348
- ' values' => ['error_margin' => 0.25, 'threshold' => 1.5],
349
- ] ));
346
+ $metadata->addPropertyConstraint('metric', new Assert\Expression(
347
+ expression: 'value + error_margin < threshold',
348
+ values: ['error_margin' => 0.25, 'threshold' => 1.5],
349
+ ));
350
350
}
351
351
352
352
// ...
0 commit comments