@@ -111,10 +111,10 @@ One way to accomplish this is with the Expression constraint:
111111 {
112112 public static function loadValidatorMetadata(ClassMetadata $metadata): void
113113 {
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+ ));
118118 }
119119
120120 // ...
@@ -200,10 +200,10 @@ assert that the expression must return ``true`` for validation to fail.
200200 {
201201 public static function loadValidatorMetadata(ClassMetadata $metadata): void
202202 {
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+ ));
207207 }
208208
209209 // ...
@@ -343,10 +343,10 @@ type (numeric, boolean, strings, null, etc.)
343343 {
344344 public static function loadValidatorMetadata(ClassMetadata $metadata): void
345345 {
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+ ));
350350 }
351351
352352 // ...
0 commit comments