2018-11-30 09:25:42 +01:00
|
|
|
--CREDITS--
|
|
|
|
Henrique Moody <henriquemoody@gmail.com>
|
2016-09-12 17:58:36 +02:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
2019-02-09 11:44:33 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-09-12 17:58:36 +02:00
|
|
|
require 'vendor/autoload.php';
|
|
|
|
|
|
|
|
use Respect\Validation\Exceptions\PhoneException;
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
|
|
|
|
$work = new stdClass();
|
2016-10-30 10:39:23 +01:00
|
|
|
$work->number = '+61.(03) 4546 5498';
|
2016-09-12 17:58:36 +02:00
|
|
|
$work->countryCode = 61;
|
|
|
|
$work->primary = true;
|
|
|
|
|
|
|
|
$personal = new stdClass();
|
2023-02-18 22:09:26 +01:00
|
|
|
$personal->number = '123';
|
2016-09-12 17:58:36 +02:00
|
|
|
$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) {
|
2018-05-22 13:42:10 +02:00
|
|
|
echo $exception->getMessage();
|
2016-09-12 17:58:36 +02:00
|
|
|
}
|
|
|
|
?>
|
2018-12-19 18:05:58 +01:00
|
|
|
--EXPECT--
|
2016-09-12 17:58:36 +02:00
|
|
|
phoneNumbers.personal.number must be a valid telephone number
|