mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
This commit introduces REUSE compliance by annotating all files with SPDX information and placing the reused licences in the LICENSES folder. We additionally removed the docheader tool which is made obsolete by this change. The main LICENSE and copyright text of the project is now not under my personal name anymore, and it belongs to "The Respect Project Contributors" instead. This change restores author names to several files, giving the appropriate attribution for contributions.
49 lines
2.4 KiB
PHP
49 lines
2.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
test('Default', catchAll(
|
|
fn() => v::phone()->assert('123'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('"123" must be a valid telephone number')
|
|
->and($fullMessage)->toBe('- "123" must be a valid telephone number')
|
|
->and($messages)->toBe(['phone' => '"123" must be a valid telephone number']),
|
|
));
|
|
|
|
test('Country-specific', catchAll(
|
|
fn() => v::phone('BR')->assert('+1 650 253 00 00'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('"+1 650 253 00 00" must be a valid telephone number for country Brazil')
|
|
->and($fullMessage)->toBe('- "+1 650 253 00 00" must be a valid telephone number for country Brazil')
|
|
->and($messages)->toBe(['phone' => '"+1 650 253 00 00" must be a valid telephone number for country Brazil']),
|
|
));
|
|
|
|
test('Inverted', catchAll(
|
|
fn() => v::not(v::phone())->assert('+55 11 91111 1111'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('"+55 11 91111 1111" must not be a valid telephone number')
|
|
->and($fullMessage)->toBe('- "+55 11 91111 1111" must not be a valid telephone number')
|
|
->and($messages)->toBe(['notPhone' => '"+55 11 91111 1111" must not be a valid telephone number']),
|
|
));
|
|
|
|
test('Default with name', catchAll(
|
|
fn() => v::named('Phone', v::phone())->assert('123'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Phone must be a valid telephone number')
|
|
->and($fullMessage)->toBe('- Phone must be a valid telephone number')
|
|
->and($messages)->toBe(['phone' => 'Phone must be a valid telephone number']),
|
|
));
|
|
|
|
test('Country-specific with name', catchAll(
|
|
fn() => v::named('Phone', v::phone('US'))->assert('123'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Phone must be a valid telephone number for country United States')
|
|
->and($fullMessage)->toBe('- Phone must be a valid telephone number for country United States')
|
|
->and($messages)->toBe(['phone' => 'Phone must be a valid telephone number for country United States']),
|
|
));
|