Phalcon\Validation\Validator\MongoId::validate PHP Method

validate() public method

public validate ( Phalcon\Validation $validation, string $attribute ) : boolean
$validation Phalcon\Validation
$attribute string
return boolean
    public function validate(Validation $validation, $attribute)
    {
        if (!extension_loaded('mongo')) {
            throw new Exception('Mongo extension is not available');
        }
        $value = $validation->getValue($attribute);
        $allowEmpty = $this->hasOption('allowEmpty');
        $result = $allowEmpty && empty($value) ? true : Id::isValid($value);
        if (!$result) {
            $message = $this->hasOption('message') ? $this->getOption('message') : 'MongoId is not valid';
            $validation->appendMessage(new Message($message, $attribute, 'MongoId'));
        }
        return $result;
    }
MongoId