Symfony Expression Constraint

Last updated on
21 August 2023

here is its docs https://symfony.com/doc/current/reference/constraints/Expression.html

it allow you write some twig-like expression :

value in ['php', 'symfony']

which provide similar function as "Specific value(s)" in previous field validation.

This is an example, You can write other expression,

Use case:

add a Expression constraint to field_test, set Expression to "value in ['php', 'symfony']", save it.

if populate field_test "php", no error message.

if populate field_test "123456", get an error message.

Note:

This constraint require "symfony/expression-language": "^6.3".

Help improve this page

Page status: No known problems

You can: