function check($value) { $pattern = '#^' . '((?<protocol>https?|ftp)://)' . '(?<domain>[-A-Z0-9.]+)' . '(?<file>/[-A-Z0-9+&@\\#/%=~_|!:,.;]*)?' . '(?<parameters>\\?[-A-Z0-9+&@\\#/%=~_|!:,.;]*)?' . '$#i'; if (!preg_match($pattern, $value, $matches)) { return $this->error('{Field} is not an url.'); } parent::check($matches['domain']); }
function testDomainRuleLocalDomain() { $rule = new lmbDomainRule('testfield'); $dataspace = new lmbSet(); $dataspace->set('testfield', 'localhost'); $this->error_list->expectNever('addError'); $rule->validate($dataspace, $this->error_list); }
protected function _checkDomain($value) { parent::check($value); }