Skip to content

[Validator] Check whether value is valid or not #11939

Closed
@webmozart

Description

@webmozart

Currently, checking whether validation succeeded (regardless of the violations) is quite expressive. What about adding methods ok() and notOk() to ConstraintViolationList which can be used in a fluent call?

// instead of
if (0 === count($validator->validate($object))) { ... }

// do
if ($validator->validate($object)->ok()) { ... }

// instead of
if (count($validator->validate($object)) > 0) { ... }

// do
if ($validator->validate($object)->notOk()) { ... }

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