sokil/php-symfony-validator-converter

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Convert validation errors from different sources to different formats

1.0.4 2017-03-19 19:27 UTC

This package is auto-updated.

Last update: 2021-09-27 19:27:53 UTC


README

Installation

Add requirement to composer:

composer require sokil/php-symfony-validator-converter

Add service to app or bundle services config:

acme.validator.error_converter:
  class: Sokil\Converter\ValidationErrorsConverter

Usage

<?php

$errors = $this->get('validator')->validate($entity);
if (count($errors) > 0) {
    $list = $this
        ->get('acme.validator.error_converter')
        ->constraintViolationListToArray($errors);
}