mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
[phonenumber validation] allow to validate against landline and mobile
phonenumbers
This commit is contained in:
@@ -21,7 +21,7 @@ use Symfony\Component\Validator\Constraint;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class PhonenumberConstraint extends Constraint
|
||||
{
|
||||
@@ -29,10 +29,12 @@ class PhonenumberConstraint extends Constraint
|
||||
|
||||
public $notLandlineMessage = "This is not a landline phonenumber";
|
||||
|
||||
public $notValidMessage = "This is not a valid phonenumber";
|
||||
|
||||
/**
|
||||
* The type of phone: landline (not able to receive sms) or mobile (can receive sms)
|
||||
*
|
||||
* @var string 'landline' or 'mobile'
|
||||
* @var string 'landline', 'mobile' or 'any'
|
||||
*/
|
||||
public $type = null;
|
||||
|
||||
|
@@ -70,10 +70,14 @@ class ValidPhonenumber extends ConstraintValidator
|
||||
$isValid = $this->phonenumberHelper->isValidPhonenumberMobile($value);
|
||||
$message = $constraint->notMobileMessage;
|
||||
break;
|
||||
case 'any':
|
||||
$isValid = $this->phonenumberHelper->isValidPhonenumberAny($value);
|
||||
$message = $constraint->notValidMessage;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \LogicException(sprintf("This type '%s' is not implemented. "
|
||||
. "Possible values are 'mobile', 'landline'"), $constraint->type);
|
||||
. "Possible values are 'mobile', 'landline' or 'any'", $constraint->type));
|
||||
}
|
||||
|
||||
if (FALSE === $isValid) {
|
||||
|
Reference in New Issue
Block a user