mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 06:45:44 +01:00
- Remove redundant "valid" prefix: Date, DateTime, DateTimeDiff, Domain, Email, Iban, Imei, Ip, Isbn, Json, LanguageCode, LeapDate, LeapYear, Luhn, MacAddress, NfeAccessKey, Nif, Nip, Pesel, Phone, Pis, PolishIdCard, PostalCode, Roman, Slug, Tld, Url, Uuid, Version. - Remove redundant "value" suffix ArrayVal, BoolVal, Countable, FloatVal, IntVal, IterableVal, NumericVal, ScalarVal, StringVal. - Standardize "consist only of" phrasing Alnum, Alpha, Cntrl, Consonant, Digit, Graph, Lowercase, Printable, Punct, Space, Spaced, Uppercase, Vowel, Xdigit. - Improve file accessibility messages Directory, Executable, File, Image, Readable, SymbolicLink, Writable. - Improve grammar and article usage CreditCard, Extension, Mimetype, Regex, Size.
42 lines
1.9 KiB
PHP
42 lines
1.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
test('Default', catchAll(
|
|
fn() => v::hetu()->assert('010106A901O'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('"010106A901O" must be a Finnish personal identity code')
|
|
->and($fullMessage)->toBe('- "010106A901O" must be a Finnish personal identity code')
|
|
->and($messages)->toBe(['hetu' => '"010106A901O" must be a Finnish personal identity code']),
|
|
));
|
|
|
|
test('Inverted', catchAll(
|
|
fn() => v::not(v::hetu())->assert('010106A9012'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('"010106A9012" must not be a Finnish personal identity code')
|
|
->and($fullMessage)->toBe('- "010106A9012" must not be a Finnish personal identity code')
|
|
->and($messages)->toBe(['notHetu' => '"010106A9012" must not be a Finnish personal identity code']),
|
|
));
|
|
|
|
test('With template', catchAll(
|
|
fn() => v::hetu()->assert('010106A901O', 'That is not a HETU'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('That is not a HETU')
|
|
->and($fullMessage)->toBe('- That is not a HETU')
|
|
->and($messages)->toBe(['hetu' => 'That is not a HETU']),
|
|
));
|
|
|
|
test('With name', catchAll(
|
|
fn() => v::named('Hetu', v::hetu())->assert('010106A901O'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Hetu must be a Finnish personal identity code')
|
|
->and($fullMessage)->toBe('- Hetu must be a Finnish personal identity code')
|
|
->and($messages)->toBe(['hetu' => 'Hetu must be a Finnish personal identity code']),
|
|
));
|