junker / phone-number-validator
PhoneNumber validation component for Symfony based frameworks (Symfony, Silex, Drupal etc.)
Installs: 1 410
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: >=5.3.9
- giggsey/libphonenumber-for-php: ~5.7|~6.0|~7.0|~8.0
Requires (Dev)
- symfony/validator: ~2.7|~3.0|~4.0
Suggests
- symfony/validator: Add a validation constraint
This package is auto-updated.
Last update: 2024-10-16 19:29:07 UTC
README
PhoneNumber validation component for Symfony based frameworks (Symfony, Silex, Drupal etc.)
Installation
The best way to install phone-number-validator is to use a Composer:
php composer.phar require junker/phone-number-validator
Examples
use Junker\PhoneNumberValidator\Constraints\PhoneNumber as AssertPhoneNumber; class AppController { ... protected function validate($data) { $fields = [ 'phone' => new AssertPhoneNumber([ 'message' => 'Wrong phone number', 'type' => "mobile", # //optional 'defaultRegion' => "GB", # //optional ]) ]; $constraint = new Assert\Collection([ 'fields' => $fields ]); return $app['validator']->validate($data, $constraint); } ... }
Based on PhoneNumberBundle (https://github.com/misd-service-development/phone-number-bundle)