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;
}