phone-number-bundle
phone-number-bundle copied to clipboard
My form submission is always invalid
I have an entity that uses the phone number type:
/**
* @ORM\Column(type="phone_number")
* @AssertPhoneNumber
*/
private $phone;
I have a form that uses the phone number type:
->add('phone', PhoneNumberType::class)
But when I submit the form, it's always invalid. And I think it's because when I type in something like +31612345678 (which is a valid phone number) then it transforms that into the text Country Code: 31 National Number: 612345678 before passing it to the validator.
That's gotta be a bug, right? Please help. 🙏
Sorry, my mistake. I still had these functions in my entity
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
which converted the phone number to string...
Hmm, something is still not right. Right now it seems to work properly when I try to validate Dutch phone numbers, but when I try to validate Nigerian phone numbers it still doesn't work. And our app is actually made for Nigerians.
Have any of you ever tried to validate Nigerian phone numbers and tried if it worked?
Hi, I also have a lot of problems with the validation using ethiopian numbers or other with 3 numbers on the indicator. For now I solve it by overriding the Validator to make it more flexible, but for long terms it's not viable.
I will consider moving on another repo like https://github.com/odolbeau/phone-number-bundle , this one seems not to be maintained anymore.