<commit_before><?php

namespace jugger\model\field;

trait FieldValidationTrait
{
    protected $_error;
    protected $_validators = [];

    public function addValidator(BaseValidator $validator)
    {
        $validator->field = $this;
        $this->_validators[] = $validator;
    }

    public function addValidators(array $validators)
    {
        foreach ($validators as $validator) {
            $this->addValidator($validator);
        }
    }

    public function getError()
    {
        return $this->_error;
    }

    public function getValidators()
    {
        return $this->_validators;
    }

    protected function validateValue($value)
    {
        $this->_error = null;
        foreach ($this->_validators as $validator) {
            if (!$validator->validate($value)) {
                $this->_error = get_class($validator);
                return false;
            }
        }
        return true;
    }<commit_msg>add field di<commit_after><?php

namespace jugger\model\field;

use jugger\model\validator\BaseValidator;

trait FieldValidationTrait
{
    protected $_error;
    protected $_validators = [];

    public function addValidator(BaseValidator $validator)
    {
        $validator->setField($this);
        $this->_validators[] = $validator;
    }

    public function addValidators(array $validators)
    {
        foreach ($validators as $validator) {
            $this->addValidator($validator);
        }
    }

    public function getError()
    {
        return $this->_error;
    }

    public function getValidators()
    {
        return $this->_validators;
    }

    protected function validateValue($value)
    {
        $this->_error = null;
        foreach ($this->_validators as $validator) {
            if (!$validator->validate($value)) {
                $this->_error = get_class($validator);
                return false;
            }
        }
        return true;
    }
{'fraction_non_alphanumeric': 0.11438923395445134, 'fraction_numerical': 0.0, 'mean_word_length': 2.0928, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2345175', 'n_tokens_mistral': 522, 'n_tokens_neox': 529, 'n_words': 109}