validate

@param string $value
@return bool
328994
public static function validate($value)
    {
        $value = Utils::toString($value);
        $tags = [
            'latest', 'earliest', 'pending'
        ];

        return in_array($value, $tags);
    }
785074
public function isValid ($value)
    {
        if (!is_numeric($value)) {
            $this->error(self::INVALID);
            return false;
        }

        if (!preg_match('/^-?[0-9]+([.,][0-9]+)?$/', $value)) {
            $this->error(self::INVALID);
            return false;
        }

        return true;
    }
370220
public function validate($value)
    {
        $result = !$this->isRequired;
        if ($this->isRequired()) {
            $result = !empty($value);
        }
        if (is_callable($this->validator)) {
            $result = call_user_func($this->validator, $value);
        }

        return $result;
    }
841269
protected function _validate($value)
    {
        $value = trim(str_replace('\\', '/', $value));
        return (is_string($value) && (preg_match(self::PATTERN, $value)) == 1);
    }
935893
public function isValid($value)
    {
        $valid = true;

        if (!empty($this->validation)) {
            if (!empty($this->label)) {
                $element = $this->label;
            } elseif (!empty($this->attributes["placeholder"])) {
                $element = $this->attributes["placeholder"];
            } else {
                $element = $this->attributes["name"];
            }

            if (substr($element, -1) == ":") {
                $element = substr($element, 0, -1);
            }

            foreach ($this->validation as $validation) {
                if (!$validation->isValid($value)) {
                    /*In the error message, %element% will be replaced by the element's label (or
                                        name if label is not provided).*/
                    $this->errors[] = str_replace("%element%", $element, $validation->getMessage());
                    $valid          = false;
                }
            }
        }

        return $valid;
    }
849695
public static function isValid($value): bool
    {
        try {
            self::decode($value);

            return true;
        } catch (\Throwable $e) {
            return false;
        }
    }
677398
protected function _validate($value)
    {
        $ret = parent::_validate($value);

        if ($ret) {
            if (strlen($value) < self::$MIN_LENGTH) {
                $ret = false;
            }
        }

        return $ret;
    }
250002
public function validate($value)
    {
        $result = Ok::unit();

        foreach ($this->allowedTypes as $type) {
            $typeChecker = preg_match('/^&/', $type) ? $this->getCustomType($type) : $this->createProperty($type);
            $result = $typeChecker->validate($value);

            if ($result instanceof Ok) {
                return $result;
            }
        }
        return $result;
    }
1055481
public function validate($value) {
        // Sadly php bug #67167 makes the following lines necessary
        if(is_null($value)) {
            return new ValidationResult(false, 'Not a valid boolean but NULL', self::ERR_NULL);
        }
        if(is_object($value)) {
            return new ValidationResult(false, 'Not a valid boolean but an object', self::ERR_OBJECT);
        }
        
        if(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)===null) {
            return new ValidationResult(false, 'Not a valid boolean', self::ERR_NOBOOLEAN);
        }        
        return new ValidationResult(true);
    }
1159397
public function validate($value)
    {
        $value = trim($value);
        $pattern = '/^[a-z]{2}-[A-Z]{2}$/';
        return (empty($value))
                || (is_string($value) && preg_match($pattern, $value) == 1);
    }
497094
public function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }

        if (empty($value)) {
            return true;
        }

        return $this->checkIfAllUniques($value);
    }
1128505
public static function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }
        if (isset($value['to']) && IdentityValidator::validate($value['to']) === false) {
            return false;
        }
        if (!isset($value['topics']) || !is_array($value['topics'])) {
            return false;
        }
        foreach ($value['topics'] as $topic) {
            if (is_array($topic)) {
                foreach ($topic as $subTopic) {
                    if (HexValidator::validate($subTopic) === false) {
                        return false;
                    }
                }
                continue;
            }
            if (HexValidator::validate($topic) === false) {
                if (!is_null($topic)) {
                    return false;
                }
            }
        }
        return true;
    }
26487
public function isValid($value)
    {
        $messages = [];
        $valid = true;
        foreach ($this->_validators as $validator) {
            if (!$validator->validates($value)) {
                $valid = false;
                $messages[] = $validator->getMessage();
            }
        }
        $this->_messages = $messages;
        return $valid;
    }
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;
    }
735805
protected function _validate($value)
    {
        $value = trim($value);
        return ((string) $value === $this->sanitize($value));
    }
286939
public static function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }
        if (isset($value['from']) && IdentityValidator::validate($value['from']) === false) {
            return false;
        }
        if (isset($value['to']) && IdentityValidator::validate($value['to']) === false) {
            return false;
        }
        if (!isset($value['topics']) || !is_array($value['topics'])) {
            return false;
        }
        foreach ($value['topics'] as $topic) {
            if (IdentityValidator::validate($topic) === false) {
                return false;
            }
        }
        if (!isset($value['payload'])) {
            return false;
        }
        if (HexValidator::validate($value['payload']) === false) {
            return false;
        }
        if (!isset($value['priority'])) {
            return false;
        }
        if (QuantityValidator::validate($value['priority']) === false) {
            return false;
        }
        if (!isset($value['ttl'])) {
            return false;
        }
        if (isset($value['ttl']) && QuantityValidator::validate($value['ttl']) === false) {
            return false;
        }
        return true;
    }
270178
public function validate($value)
    {
        $date = \DateTime::createFromFormat($this->specification, $value);

        return $date !== false;
    }