Skip to content

Halt subsequent constraints on first failure #2947

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy