Validate value
@see \Phramework\Validate\ValidateResult for ValidateResult object
@param  mixed $value Value to validate
@return ValidateResult
553387
public function validate($value)
    {
        $return = $this->validateCommon($value, new ValidateResult($value, true));

        if ($return->status === false) {
            return $return;
        }

        return $this->validateNumber($return->value);
    }
821277
public function setValue($value)
    {
        NumericValidator::validate($value, "Value");
        $value = Formatter::formatToPrice($value, $this->getCurrency());
        $this->value = $value;
        return $this;
    }
668605
public function validate($value)
    {
        return is_scalar($value) ? Ok::unit() : Error::unit([ Error::NON_SCALAR ]);
    }
227744
protected function validate($value)
    {
        $ret = ($value instanceof \Traversable ||
            $value instanceof \stdClass ||
            is_array($value));
        if (!$ret) {
            $this->messenger->add(new StringType('value is not traversable'));
        }

        return $ret;
    }
228999
public function validateValue($value) {

        $model = &$this->_model;

        $attribute = $this->_attributeName;
        if ((!is_array($model->$attribute) || !count($model->$attribute)) && $this->skipOnEmpty) {
            return '';
        }

        $result = count($model->$attribute) > 0;
        $class = $this->baseModel;

        foreach ($model->$attribute as $_key => &$_model) {
            /** @var $_model Model|ActiveRecord */
            if (!is_object($_model)) {
                if (!is_array($_model)) {
                    $_model = [$this->attribute ? : $this->_attributeName => $_model];
                }
                $_model = new $class($_model);
            }

            $result = $_model->validate() && $result;
        }

        return $result || (sizeof($model->$attribute)==1 && $this->skipOnEmpty) ? null : [$this->message, $result];
    }
26437
public function validate($value)
    {
        return is_array($value) ? $this->valueSchema->validate($value) : Error::unit([ Error::NON_ARRAY ]);
    }
800931
public function validate($value)
    {
        return in_array($value, $this->choices) ? Ok::unit() : Error::unit([ Error::INVALID_CHOICE ]);
    }
1100481
protected function validate($value)
    {
        if (!parent::validate($value)) {
            return false;
        }

        if (count($value) < $this->min) {
            $this->messenger->add(new StringType(self::ERR_MIN));
            return false;
        }

        if ($this->max !== -1 && (count($value) > $this->max)) {
            $this->messenger->add(new StringType(self::ERR_MAX));
            return false;
        }

        $validator = $this->validator;
        foreach ($value as $k => $v) {
            if (!$validator($v, $this->messenger)) {
                $this->messenger->add(new StringType(sprintf(self::ERR_ITEM, (string)$k)));
                return false;
            }
        }

        return true;
    }
676751
protected function isValid($value)
    {
        if (is_null($value)) {
            return;
        }

        if (is_array($value) || ($value instanceof \ArrayAccess) || is_object($value)) {
            foreach ($this->options['shape'] as $key => $subValidator) {
                if (is_array($value) || ($value instanceof \ArrayAccess)) {
                    if (array_key_exists($key, $value)) {
                        $subValue = $value[$key];
                    } else {
                        $subValue = null;
                    }
                } elseif (ObjectAccess::isPropertyGettable($value, $key)) {
                    $subValue = ObjectAccess::getPropertyPath($value, $key);
                } else {
                    $subValue = null;
                }

                if ($subValidator instanceof ValidatorInterface) {
                    $subResult = $subValidator->validate($subValue);
                    if ($subResult->hasErrors()) {
                        $this->result->forProperty($key)->merge($subResult);
                    }
                }
            }
        } else {
            $this->addError('Shape-value is expected to be an array or implement ArrayAccess', 1515070099);
        }
    }
449557
public static function validateDate($value)
    {
        if (\is_string($value) && \strlen($value) > 0 && (
                false !== ($date1 = \DateTime::createFromFormat('Y-m-d\TH:i:sP', $value))
                || false !== \DateTime::createFromFormat('Y-m-d', $value)
            )
        ) {
            $format = 'Y-m-d';

            if (false !== $date1) {
                $format = 'c';
            }

            return \htmlentities((new \DateTime($value))->format($format));
        }

        return false;
    }
427053
protected function validate(&$value)
    {
        $mongoId = Entity::getInstance()->getDatabase()->isId($value);

        if (!$this->isNull($value) && !is_array($value) && !$this->isInstanceOf($value, AbstractEntity::class) && !$mongoId) {
            $this->expected('entity ID, instance of ' . AbstractEntity::class . ' or null', gettype($value));
        }

        return $this;
    }
873849
public function validate($value) {
        if(!is_string($value)) {
            throw new DataType('value', 'string', $value);
        }
        
        if(!password_verify($value, $this->hash)) {
            return new ValidationResult(false, 'Wrong password');
        }        
        return new ValidationResult(true);
    }
614088
public function validate($value)
    {
        if (!is_array($value)) {
            return Error::unit([ Error::NON_ARRAY ]);
        }

        $errors = [];
        foreach ($value as $pos => $item) {
            $result = parent::validate($item);
            if ($result instanceof Error) {
                $errors[$pos] = $result->unwrap();
            }
        }

        return empty($errors) ? Ok::unit() : Error::unit($errors);
    }
946025
protected function validateCommon($value, $validateResult)
    {
        //While current status of validation is true,
        //keep validating against common keywords

        //validate against enum using validateEnum
        if ($validateResult->status === true && $this->enum) {
            $validateResult = $this->validateEnum($value, $validateResult->value);

            if ($validateResult->status !== true) {
                //failed to validate against enum
                return $validateResult;
            }
        }

        //validate against not
        if ($validateResult->status === true && $this->not) {
            $validateResult = $this->validateNot($value, $validateResult->value);

            if ($validateResult->status !== true) {
                //failed to validate against not
                return $validateResult;
            }
        }

        return $this->runValidateCallback($validateResult);
    }
302997
protected function validate(&$value)
    {
        if ($this->str($value)->contains(',')) {
            $value = $this->str($value)->replace(',', '.')->val();
        }
        $value = floatval($value);

        if (!$this->isNumber($value)) {
            $this->expected('number', gettype($value));
        }

        parent::validate($value);

        return $this;
    }
401059
public function validate($value) : Result
    {
        return array_reduce(
            $this->restrictions,
            function ($result, $restriction) use ($value) : Result {
                if ($result->isFatal()) {
                    return $result;
                }

                return $result->concat($restriction($value));
            },
            Result::success()
        );
    }
53632
protected function validateRequired( $value )
	{
		if( is_string( $value )) {
			$value = trim( $value );
		}
		return is_null( $value ) || empty( $value )
			? false
			: true;
	}