8000 Halt subsequent constraints on first failure · Issue #2947 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Halt subsequent constraints on first failure #2947
Closed
@satazor

Description

@satazor

Let's say that an entity have the following constraints applied to a property:

/*
 * @Assert\NotBlank(
 *     message="The username cannot be blank."
 * )
 * @Assert\MinLength(
 *     limit=2,
 *     message="The username must have at least {{ limit }} characters."
 * )
 * @Assert\Regex(
 *     pattern="/^[a-z][a-z0-9\-_]+$/i",
 *     message="The username must start with a letter and can contain alphanumerical characters, -, and _."
 * )

When a form validates the propery:

  • If the property is blank, the min length and regex constraints are not applied
  • If the property is not blank but the the min length constraint fails, the regex constraint is still applied, resulting in two errors

I understand that this was the desired default behaviour, but for some use cases one would want to halt on first failure.
I remember that symfony1.x had the halt_on_error option for this, though I couldn't found any reference to achieve this in symfony2.

Is this an undocumented feature? or is this still not implemented?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0