Do not try to validate empty strings as email. If it's required but empty, give the required validation message.

This commit is contained in:
nathan 2023-02-22 15:17:17 -07:00
parent 4311eebdc9
commit 46389e72f7

View File

@ -189,7 +189,7 @@ class Taglist extends Etemplate\Widget
} }
else else
{ {
if(str_contains($this->type, 'email') && !preg_match(Url::EMAIL_PREG, $val) && if($val !== '' && str_contains($this->type, 'email') && !preg_match(Url::EMAIL_PREG, $val) &&
!($this->attrs['domainOptional'] && preg_match(Taglist::EMAIL_PREG_NO_DOMAIN, $val)) && !($this->attrs['domainOptional'] && preg_match(Taglist::EMAIL_PREG_NO_DOMAIN, $val)) &&
// Allow merge placeholders. Might be a better way to do this though. // Allow merge placeholders. Might be a better way to do this though.
!preg_match('/{{.+}}|\$\$.+\$\$/', $val) !preg_match('/{{.+}}|\$\$.+\$\$/', $val)