/plushcap/analysis/twilio/build-phone-number-validator-laravel

Build a Phone Number Validator with Laravel

What's this blog post about?

A custom Laravel validation rule was built to validate phone numbers from any country in the world, using Twilio's Lookup API. The rule is encapsulated in a service class that interacts with Twilio's API to verify if a given string forms a valid phone number. A controller class uses this rule to validate phone numbers received through POST requests. The validation logic can be simplified by registering the service as part of Laravel's Service Container, allowing it to be used anywhere in the application through dependency injection.

Company
Twilio

Date published
July 27, 2021

Author(s)
Matthew Setter

Word count
2251

Language
English

Hacker News points
None found.


By Matt Makai. 2021-2024.