<?php

namespace Application\Service\Extension\ValidatorV2\validators;

class DefaultValidator extends BaseValidator
{
    protected $defaultValue;

    public function value($value): DefaultValidator
    {
        $this->defaultValue = $value;

        return $this;
    }

    public function isValid(&$value): bool
    {
        foreach ($this->validationAttributes as $validationAttribute) {
            if (!isset($value[$validationAttribute])) {
                $value[$validationAttribute] = $this->defaultValue;
            }
        }

        return true;
    }
}