Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Latest commit

 

History

History
32 lines (27 loc) · 585 Bytes

NestedErrorMessages.md

File metadata and controls

32 lines (27 loc) · 585 Bytes

NestedErrorMessages

<?php

use Chubbyphp\Validation\Error\Error;
use Chubbyphp\Validation\Error\NestedErrorMessages;

$error = new Error(
    'path.to.property',
    'constraint.constraint.invalidtype',
    ['type' => 'array']
);

$errorMessages = new NestedErrorMessages(
    [$error],
    function (string $key, array $arguments) {
        return $key;
    }
);

$errorMessages->getMessages();
// [
//     'path' => [
//         'to' => [
//             'property' => [
//                 'constraint.constraint.invalidtype'
//             ]
//         ]
//     ]
// ]