Php Phalcon-同一字段上的条件验证
我想验证朋友字段。它可能是电子邮件地址或手机号码。如何验证两个输入值(电子邮件/手机) 我的设想是:Php Phalcon-同一字段上的条件验证,php,phalcon,Php,Phalcon,我想验证朋友字段。它可能是电子邮件地址或手机号码。如何验证两个输入值(电子邮件/手机) 我的设想是: $this->add('refer_type', new PresenceOf(array( 'message' => self::fetchErrorMessage('Refer Type', 'ERROR_REQUIRED')))) ->add('refer_type', new InclusionIn(array( '
$this->add('refer_type', new PresenceOf(array(
'message' => self::fetchErrorMessage('Refer Type', 'ERROR_REQUIRED'))))
->add('refer_type', new InclusionIn(array(
'message' => self::fetchErrorMessage('Refer Type', 'ERROR_VALID'),
'domain' => ['mobile', 'email'])));
如果referetype是mobile,那么我将验证它,如下所示:
$this->add('friend', new PresenceOf(array(
'message' => self::fetchErrorMessage('Friend', 'ERROR_REQUIRED'))))
->add('friend', new Regex(array(
'pattern' => '/^[0-9]*$/',
'message' => self::fetchErrorMessage('friend', 'ERROR_VALID'))));
电子邮件也一样,但我想同时检查两个验证(电子邮件/手机)关于同一字段。我建议您编写自定义验证程序(FriendValidator)。您可以在(Check IpValidator)上找到一个示例,然后在表单中使用您的FriendValidator。我建议您编写自定义验证器(FriendValidator)。您可以在(Check IpValidator)找到一个示例,然后在表单中使用FriendValidator