'Invalid type given; string expected', self::INVALID => 'Invalid UUID format', ]; /** * Returns true if and only if $value meets the validation requirements. * * If $value fails validation, then this method returns false, and * getMessages() will return an array of messages that explain why the * validation failed. * * @param mixed $value * * @return bool * * @throws Exception\RuntimeException If validation of $value is impossible */ public function isValid($value) { if (! is_string($value)) { $this->error(self::NOT_STRING); return false; } $this->setValue($value); if (empty($value) || $value !== '00000000-0000-0000-0000-000000000000' && ! preg_match(self::REGEX_UUID, $value) ) { $this->error(self::INVALID); return false; } return true; } }