sokil/php-symfony-validator-converter

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: 2024-11-28 01:58:48 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);
}