<?php

namespace Lucent\Schema\Validator;


use Exception;


final class ValidatorException extends Exception
{
    private array $validatorErrors;

    // Redefine the exception so message isn't optional
    public function __construct(array $message, int $code = 0, Exception $previous = null)
    {
        // make sure everything is assigned properly
        $this->validatorErrors = $message;
        parent::__construct("You have one or more validation errors", $code, $previous);
    }

    public function getValidatorErrors(): array
    {
        return $this->validatorErrors;
    }

    public function getFirstValidatorError(): array
    {
        return (array)array_shift($this->validatorErrors);
    }


}
