mirror of
https://github.com/Respect/Validation.git
synced 2024-06-03 14:22:16 +02:00
df3f1c0ea7
All the PHP files have the "@author" annotation to make clear which people have contributed to that specific file, however, there is no such thing in the PHPT files. This commit will add the "CREDITS" section to the PHPT files. The list of authors is created from the output of the `git blame` command. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
--CREDITS--
|
|
Henrique Moody <henriquemoody@gmail.com>
|
|
--FILE--
|
|
<?php
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
use Respect\Validation\Exceptions\PhoneException;
|
|
use Respect\Validation\Validator as v;
|
|
|
|
$work = new stdClass();
|
|
$work->number = '+61.(03) 4546 5498';
|
|
$work->countryCode = 61;
|
|
$work->primary = true;
|
|
|
|
$personal = new stdClass();
|
|
$personal->number = '+61.0406 464 890';
|
|
$personal->country = 61;
|
|
$personal->primary = false;
|
|
|
|
$phoneNumbers = new stdClass();
|
|
$phoneNumbers->personal = $personal;
|
|
$phoneNumbers->work = $work;
|
|
|
|
$validateThis = ['phoneNumbers' => $phoneNumbers];
|
|
|
|
try {
|
|
v::create()
|
|
->keyNested('phoneNumbers.personal.country', v::intType(), false)
|
|
->keyNested('phoneNumbers.personal.number', v::phone(), false)
|
|
->keyNested('phoneNumbers.personal.primary', v::boolType(), false)
|
|
->keyNested('phoneNumbers.work.country', v::intType(), false)
|
|
->keyNested('phoneNumbers.work.number', v::phone(), false)
|
|
->keyNested('phoneNumbers.work.primary', v::boolType(), false)
|
|
->check($validateThis);
|
|
} catch (PhoneException $exception) {
|
|
echo $exception->getMessage();
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
phoneNumbers.personal.number must be a valid telephone number
|