Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ValidationException
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getErrors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Engine\Domain\Exception;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use RuntimeException;
12
13/**
14 * Validation Domain Exception.
15 *
16 * Thrown by UniversalValidationEngine when one or more field values
17 * fail validation rules. Carries a structured error map for API responses.
18 *
19 * @package App\Core\Engine\Domain\Exception
20 */
21final class ValidationException extends RuntimeException
22{
23    /**
24     * ValidationException constructor.
25     *
26     * @param array<string, string> $errors Map of field_key => error message.
27     */
28    public function __construct(private readonly array $errors)
29    {
30        parent::__construct('Validation failed: ' . implode('; ', $errors));
31    }
32
33    /**
34     * Returns the full error map keyed by field_key.
35     *
36     * @return array<string, string> Field validation error messages.
37     */
38    public function getErrors(): array
39    {
40        return $this->errors;
41    }
42}