mirror of
https://github.com/Respect/Validation.git
synced 2024-06-28 02:00:06 +02:00
Merge branch '2.3'
This commit is contained in:
commit
bd325668a9
6
.github/workflows/continuous-integration.yml
vendored
6
.github/workflows/continuous-integration.yml
vendored
|
@ -19,9 +19,9 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- "8.0"
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -62,7 +62,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: 8.1
|
||||
coverage: pcov
|
||||
extensions: uopz
|
||||
tools: pecl
|
||||
|
@ -96,7 +96,7 @@ jobs:
|
|||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
php-version: 8.3
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Versioning Changes:
|
||||
|
||||
- Dropped support for PHP 7.4.
|
||||
- Dropped support for PHP 8.0 and below.
|
||||
- Updated dev dependencies
|
||||
|
||||
Deprecations:
|
||||
|
@ -15,6 +15,9 @@ Deprecations:
|
|||
Fixes:
|
||||
|
||||
- `KeySet` now reports which extra keys are causing the rule to fail.
|
||||
- Ensure empty strings are never a valid currency code
|
||||
- Do not hide messages on EachException
|
||||
- Dot not throw exception when validating an uninitialized property
|
||||
|
||||
Changes:
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ final class HelloWorldTest extends RuleTestCase
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function providerForValidInput(): array
|
||||
public static function providerForValidInput(): array
|
||||
{
|
||||
$rule = new HelloWorld();
|
||||
|
||||
|
@ -169,7 +169,7 @@ final class HelloWorldTest extends RuleTestCase
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function providerForInvalidInput(): array
|
||||
public static function providerForInvalidInput(): array
|
||||
{
|
||||
$rule = new HelloWorld();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.0 || ^8.1 || ^8.2",
|
||||
"php": "^8.1 || ^8.2",
|
||||
"respect/stringifier": "^0.2.0",
|
||||
"symfony/polyfill-mbstring": "^1.2"
|
||||
},
|
||||
|
@ -32,7 +32,7 @@
|
|||
"phpstan/phpstan-phpunit": "^1.3",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"psr/http-message": "^1.0",
|
||||
"respect/coding-standard": "^3.0",
|
||||
"respect/coding-standard": "^4.0",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -51,7 +51,10 @@
|
|||
"psr-4": {
|
||||
"Respect\\Validation\\": "tests/unit/",
|
||||
"Respect\\Validation\\Test\\": "tests/library/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"tests/integration/lib/helpers.php"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"docheader": "vendor/bin/docheader check library/ tests/",
|
||||
|
|
|
@ -1,551 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
// Copyright (c) https://publicsuffix.org
|
||||
// SPDX-License-Identifier: MPL-2.0-no-copyleft-exception
|
||||
return [
|
||||
'ACADEMY.MUSEUM',
|
||||
'AGRICULTURE.MUSEUM',
|
||||
'AIR.MUSEUM',
|
||||
'AIRGUARD.MUSEUM',
|
||||
'ALABAMA.MUSEUM',
|
||||
'ALASKA.MUSEUM',
|
||||
'AMBER.MUSEUM',
|
||||
'AMBULANCE.MUSEUM',
|
||||
'AMERICAN.MUSEUM',
|
||||
'AMERICANA.MUSEUM',
|
||||
'AMERICANANTIQUES.MUSEUM',
|
||||
'AMERICANART.MUSEUM',
|
||||
'AMSTERDAM.MUSEUM',
|
||||
'AND.MUSEUM',
|
||||
'ANNEFRANK.MUSEUM',
|
||||
'ANTHRO.MUSEUM',
|
||||
'ANTHROPOLOGY.MUSEUM',
|
||||
'ANTIQUES.MUSEUM',
|
||||
'AQUARIUM.MUSEUM',
|
||||
'ARBORETUM.MUSEUM',
|
||||
'ARCHAEOLOGICAL.MUSEUM',
|
||||
'ARCHAEOLOGY.MUSEUM',
|
||||
'ARCHITECTURE.MUSEUM',
|
||||
'ART.MUSEUM',
|
||||
'ARTANDDESIGN.MUSEUM',
|
||||
'ARTCENTER.MUSEUM',
|
||||
'ARTDECO.MUSEUM',
|
||||
'ARTEDUCATION.MUSEUM',
|
||||
'ARTGALLERY.MUSEUM',
|
||||
'ARTS.MUSEUM',
|
||||
'ARTSANDCRAFTS.MUSEUM',
|
||||
'ASMATART.MUSEUM',
|
||||
'ASSASSINATION.MUSEUM',
|
||||
'ASSISI.MUSEUM',
|
||||
'ASSOCIATION.MUSEUM',
|
||||
'ASTRONOMY.MUSEUM',
|
||||
'ATLANTA.MUSEUM',
|
||||
'AUSTIN.MUSEUM',
|
||||
'AUSTRALIA.MUSEUM',
|
||||
'AUTOMOTIVE.MUSEUM',
|
||||
'AVIATION.MUSEUM',
|
||||
'AXIS.MUSEUM',
|
||||
'BADAJOZ.MUSEUM',
|
||||
'BAGHDAD.MUSEUM',
|
||||
'BAHN.MUSEUM',
|
||||
'BALE.MUSEUM',
|
||||
'BALTIMORE.MUSEUM',
|
||||
'BARCELONA.MUSEUM',
|
||||
'BASEBALL.MUSEUM',
|
||||
'BASEL.MUSEUM',
|
||||
'BATHS.MUSEUM',
|
||||
'BAUERN.MUSEUM',
|
||||
'BEAUXARTS.MUSEUM',
|
||||
'BEELDENGELUID.MUSEUM',
|
||||
'BELLEVUE.MUSEUM',
|
||||
'BERGBAU.MUSEUM',
|
||||
'BERKELEY.MUSEUM',
|
||||
'BERLIN.MUSEUM',
|
||||
'BERN.MUSEUM',
|
||||
'BIBLE.MUSEUM',
|
||||
'BILBAO.MUSEUM',
|
||||
'BILL.MUSEUM',
|
||||
'BIRDART.MUSEUM',
|
||||
'BIRTHPLACE.MUSEUM',
|
||||
'BONN.MUSEUM',
|
||||
'BOSTON.MUSEUM',
|
||||
'BOTANICAL.MUSEUM',
|
||||
'BOTANICALGARDEN.MUSEUM',
|
||||
'BOTANICGARDEN.MUSEUM',
|
||||
'BOTANY.MUSEUM',
|
||||
'BRANDYWINEVALLEY.MUSEUM',
|
||||
'BRASIL.MUSEUM',
|
||||
'BRISTOL.MUSEUM',
|
||||
'BRITISH.MUSEUM',
|
||||
'BRITISHCOLUMBIA.MUSEUM',
|
||||
'BROADCAST.MUSEUM',
|
||||
'BRUNEL.MUSEUM',
|
||||
'BRUSSEL.MUSEUM',
|
||||
'BRUSSELS.MUSEUM',
|
||||
'BRUXELLES.MUSEUM',
|
||||
'BUILDING.MUSEUM',
|
||||
'BURGHOF.MUSEUM',
|
||||
'BUS.MUSEUM',
|
||||
'BUSHEY.MUSEUM',
|
||||
'CADAQUES.MUSEUM',
|
||||
'CALIFORNIA.MUSEUM',
|
||||
'CAMBRIDGE.MUSEUM',
|
||||
'CAN.MUSEUM',
|
||||
'CANADA.MUSEUM',
|
||||
'CAPEBRETON.MUSEUM',
|
||||
'CARRIER.MUSEUM',
|
||||
'CARTOONART.MUSEUM',
|
||||
'CASADELAMONEDA.MUSEUM',
|
||||
'CASTLE.MUSEUM',
|
||||
'CASTRES.MUSEUM',
|
||||
'CELTIC.MUSEUM',
|
||||
'CENTER.MUSEUM',
|
||||
'CHATTANOOGA.MUSEUM',
|
||||
'CHELTENHAM.MUSEUM',
|
||||
'CHESAPEAKEBAY.MUSEUM',
|
||||
'CHICAGO.MUSEUM',
|
||||
'CHILDREN.MUSEUM',
|
||||
'CHILDRENS.MUSEUM',
|
||||
'CHILDRENSGARDEN.MUSEUM',
|
||||
'CHIROPRACTIC.MUSEUM',
|
||||
'CHOCOLATE.MUSEUM',
|
||||
'CHRISTIANSBURG.MUSEUM',
|
||||
'CINCINNATI.MUSEUM',
|
||||
'CINEMA.MUSEUM',
|
||||
'CIRCUS.MUSEUM',
|
||||
'CIVILISATION.MUSEUM',
|
||||
'CIVILIZATION.MUSEUM',
|
||||
'CIVILWAR.MUSEUM',
|
||||
'CLINTON.MUSEUM',
|
||||
'CLOCK.MUSEUM',
|
||||
'COAL.MUSEUM',
|
||||
'COASTALDEFENCE.MUSEUM',
|
||||
'CODY.MUSEUM',
|
||||
'COLDWAR.MUSEUM',
|
||||
'COLLECTION.MUSEUM',
|
||||
'COLONIALWILLIAMSBURG.MUSEUM',
|
||||
'COLORADOPLATEAU.MUSEUM',
|
||||
'COLUMBIA.MUSEUM',
|
||||
'COLUMBUS.MUSEUM',
|
||||
'COMMUNICATION.MUSEUM',
|
||||
'COMMUNICATIONS.MUSEUM',
|
||||
'COMMUNITY.MUSEUM',
|
||||
'COMPUTER.MUSEUM',
|
||||
'COMPUTERHISTORY.MUSEUM',
|
||||
'CONTEMPORARY.MUSEUM',
|
||||
'CONTEMPORARYART.MUSEUM',
|
||||
'CONVENT.MUSEUM',
|
||||
'COPENHAGEN.MUSEUM',
|
||||
'CORPORATION.MUSEUM',
|
||||
'CORVETTE.MUSEUM',
|
||||
'COSTUME.MUSEUM',
|
||||
'COUNTRYESTATE.MUSEUM',
|
||||
'COUNTY.MUSEUM',
|
||||
'CRAFTS.MUSEUM',
|
||||
'CRANBROOK.MUSEUM',
|
||||
'CREATION.MUSEUM',
|
||||
'CULTURAL.MUSEUM',
|
||||
'CULTURALCENTER.MUSEUM',
|
||||
'CULTURE.MUSEUM',
|
||||
'CYBER.MUSEUM',
|
||||
'CYMRU.MUSEUM',
|
||||
'DALI.MUSEUM',
|
||||
'DALLAS.MUSEUM',
|
||||
'DATABASE.MUSEUM',
|
||||
'DDR.MUSEUM',
|
||||
'DECORATIVEARTS.MUSEUM',
|
||||
'DELAWARE.MUSEUM',
|
||||
'DELMENHORST.MUSEUM',
|
||||
'DENMARK.MUSEUM',
|
||||
'DEPOT.MUSEUM',
|
||||
'DESIGN.MUSEUM',
|
||||
'DETROIT.MUSEUM',
|
||||
'DINOSAUR.MUSEUM',
|
||||
'DISCOVERY.MUSEUM',
|
||||
'DOLLS.MUSEUM',
|
||||
'DONOSTIA.MUSEUM',
|
||||
'DURHAM.MUSEUM',
|
||||
'EASTAFRICA.MUSEUM',
|
||||
'EASTCOAST.MUSEUM',
|
||||
'EDUCATION.MUSEUM',
|
||||
'EDUCATIONAL.MUSEUM',
|
||||
'EGYPTIAN.MUSEUM',
|
||||
'EISENBAHN.MUSEUM',
|
||||
'ELBURG.MUSEUM',
|
||||
'ELVENDRELL.MUSEUM',
|
||||
'EMBROIDERY.MUSEUM',
|
||||
'ENCYCLOPEDIC.MUSEUM',
|
||||
'ENGLAND.MUSEUM',
|
||||
'ENTOMOLOGY.MUSEUM',
|
||||
'ENVIRONMENT.MUSEUM',
|
||||
'ENVIRONMENTALCONSERVATION.MUSEUM',
|
||||
'EPILEPSY.MUSEUM',
|
||||
'ESSEX.MUSEUM',
|
||||
'ESTATE.MUSEUM',
|
||||
'ETHNOLOGY.MUSEUM',
|
||||
'EXETER.MUSEUM',
|
||||
'EXHIBITION.MUSEUM',
|
||||
'FAMILY.MUSEUM',
|
||||
'FARM.MUSEUM',
|
||||
'FARMEQUIPMENT.MUSEUM',
|
||||
'FARMERS.MUSEUM',
|
||||
'FARMSTEAD.MUSEUM',
|
||||
'FIELD.MUSEUM',
|
||||
'FIGUERES.MUSEUM',
|
||||
'FILATELIA.MUSEUM',
|
||||
'FILM.MUSEUM',
|
||||
'FINEART.MUSEUM',
|
||||
'FINEARTS.MUSEUM',
|
||||
'FINLAND.MUSEUM',
|
||||
'FLANDERS.MUSEUM',
|
||||
'FLORIDA.MUSEUM',
|
||||
'FORCE.MUSEUM',
|
||||
'FORTMISSOULA.MUSEUM',
|
||||
'FORTWORTH.MUSEUM',
|
||||
'FOUNDATION.MUSEUM',
|
||||
'FRANCAISE.MUSEUM',
|
||||
'FRANKFURT.MUSEUM',
|
||||
'FRANZISKANER.MUSEUM',
|
||||
'FREEMASONRY.MUSEUM',
|
||||
'FREIBURG.MUSEUM',
|
||||
'FRIBOURG.MUSEUM',
|
||||
'FROG.MUSEUM',
|
||||
'FUNDACIO.MUSEUM',
|
||||
'FURNITURE.MUSEUM',
|
||||
'GALLERY.MUSEUM',
|
||||
'GARDEN.MUSEUM',
|
||||
'GATEWAY.MUSEUM',
|
||||
'GEELVINCK.MUSEUM',
|
||||
'GEMOLOGICAL.MUSEUM',
|
||||
'GEOLOGY.MUSEUM',
|
||||
'GEORGIA.MUSEUM',
|
||||
'GIESSEN.MUSEUM',
|
||||
'GLAS.MUSEUM',
|
||||
'GLASS.MUSEUM',
|
||||
'GORGE.MUSEUM',
|
||||
'GRANDRAPIDS.MUSEUM',
|
||||
'GRAZ.MUSEUM',
|
||||
'GUERNSEY.MUSEUM',
|
||||
'HALLOFFAME.MUSEUM',
|
||||
'HAMBURG.MUSEUM',
|
||||
'HANDSON.MUSEUM',
|
||||
'HARVESTCELEBRATION.MUSEUM',
|
||||
'HAWAII.MUSEUM',
|
||||
'HEALTH.MUSEUM',
|
||||
'HEIMATUNDUHREN.MUSEUM',
|
||||
'HELLAS.MUSEUM',
|
||||
'HELSINKI.MUSEUM',
|
||||
'HEMBYGDSFORBUND.MUSEUM',
|
||||
'HERITAGE.MUSEUM',
|
||||
'HISTOIRE.MUSEUM',
|
||||
'HISTORICAL.MUSEUM',
|
||||
'HISTORICALSOCIETY.MUSEUM',
|
||||
'HISTORICHOUSES.MUSEUM',
|
||||
'HISTORISCH.MUSEUM',
|
||||
'HISTORISCHES.MUSEUM',
|
||||
'HISTORY.MUSEUM',
|
||||
'HISTORYOFSCIENCE.MUSEUM',
|
||||
'HOROLOGY.MUSEUM',
|
||||
'HOUSE.MUSEUM',
|
||||
'HUMANITIES.MUSEUM',
|
||||
'ILLUSTRATION.MUSEUM',
|
||||
'IMAGEANDSOUND.MUSEUM',
|
||||
'INDIAN.MUSEUM',
|
||||
'INDIANA.MUSEUM',
|
||||
'INDIANAPOLIS.MUSEUM',
|
||||
'INDIANMARKET.MUSEUM',
|
||||
'INTELLIGENCE.MUSEUM',
|
||||
'INTERACTIVE.MUSEUM',
|
||||
'IRAQ.MUSEUM',
|
||||
'IRON.MUSEUM',
|
||||
'ISLEOFMAN.MUSEUM',
|
||||
'JAMISON.MUSEUM',
|
||||
'JEFFERSON.MUSEUM',
|
||||
'JERUSALEM.MUSEUM',
|
||||
'JEWELRY.MUSEUM',
|
||||
'JEWISH.MUSEUM',
|
||||
'JEWISHART.MUSEUM',
|
||||
'JFK.MUSEUM',
|
||||
'JOURNALISM.MUSEUM',
|
||||
'JUDAICA.MUSEUM',
|
||||
'JUDYGARLAND.MUSEUM',
|
||||
'JUEDISCHES.MUSEUM',
|
||||
'JUIF.MUSEUM',
|
||||
'KARATE.MUSEUM',
|
||||
'KARIKATUR.MUSEUM',
|
||||
'KIDS.MUSEUM',
|
||||
'KOEBENHAVN.MUSEUM',
|
||||
'KOELN.MUSEUM',
|
||||
'KUNST.MUSEUM',
|
||||
'KUNSTSAMMLUNG.MUSEUM',
|
||||
'KUNSTUNDDESIGN.MUSEUM',
|
||||
'LABOR.MUSEUM',
|
||||
'LABOUR.MUSEUM',
|
||||
'LAJOLLA.MUSEUM',
|
||||
'LANCASHIRE.MUSEUM',
|
||||
'LANDES.MUSEUM',
|
||||
'LANS.MUSEUM',
|
||||
'LARSSON.MUSEUM',
|
||||
'LEWISMILLER.MUSEUM',
|
||||
'LINCOLN.MUSEUM',
|
||||
'LINZ.MUSEUM',
|
||||
'LIVING.MUSEUM',
|
||||
'LIVINGHISTORY.MUSEUM',
|
||||
'LOCALHISTORY.MUSEUM',
|
||||
'LONDON.MUSEUM',
|
||||
'LOSANGELES.MUSEUM',
|
||||
'LOUVRE.MUSEUM',
|
||||
'LOYALIST.MUSEUM',
|
||||
'LUCERNE.MUSEUM',
|
||||
'LUXEMBOURG.MUSEUM',
|
||||
'LUZERN.MUSEUM',
|
||||
'MAD.MUSEUM',
|
||||
'MADRID.MUSEUM',
|
||||
'MALLORCA.MUSEUM',
|
||||
'MANCHESTER.MUSEUM',
|
||||
'MANSION.MUSEUM',
|
||||
'MANSIONS.MUSEUM',
|
||||
'MANX.MUSEUM',
|
||||
'MARBURG.MUSEUM',
|
||||
'MARITIME.MUSEUM',
|
||||
'MARITIMO.MUSEUM',
|
||||
'MARYLAND.MUSEUM',
|
||||
'MARYLHURST.MUSEUM',
|
||||
'MEDIA.MUSEUM',
|
||||
'MEDICAL.MUSEUM',
|
||||
'MEDIZINHISTORISCHES.MUSEUM',
|
||||
'MEERES.MUSEUM',
|
||||
'MEMORIAL.MUSEUM',
|
||||
'MESAVERDE.MUSEUM',
|
||||
'MICHIGAN.MUSEUM',
|
||||
'MIDATLANTIC.MUSEUM',
|
||||
'MILITARY.MUSEUM',
|
||||
'MILL.MUSEUM',
|
||||
'MINERS.MUSEUM',
|
||||
'MINING.MUSEUM',
|
||||
'MINNESOTA.MUSEUM',
|
||||
'MISSILE.MUSEUM',
|
||||
'MISSOULA.MUSEUM',
|
||||
'MODERN.MUSEUM',
|
||||
'MOMA.MUSEUM',
|
||||
'MONEY.MUSEUM',
|
||||
'MONMOUTH.MUSEUM',
|
||||
'MONTICELLO.MUSEUM',
|
||||
'MONTREAL.MUSEUM',
|
||||
'MOSCOW.MUSEUM',
|
||||
'MOTORCYCLE.MUSEUM',
|
||||
'MUENCHEN.MUSEUM',
|
||||
'MUENSTER.MUSEUM',
|
||||
'MULHOUSE.MUSEUM',
|
||||
'MUNCIE.MUSEUM',
|
||||
'MUSEET.MUSEUM',
|
||||
'MUSEUMCENTER.MUSEUM',
|
||||
'MUSEUMVERENIGING.MUSEUM',
|
||||
'MUSIC.MUSEUM',
|
||||
'NATIONAL.MUSEUM',
|
||||
'NATIONALFIREARMS.MUSEUM',
|
||||
'NATIONALHERITAGE.MUSEUM',
|
||||
'NATIVEAMERICAN.MUSEUM',
|
||||
'NATURALHISTORY.MUSEUM',
|
||||
'NATURALHISTORYMUSEUM.MUSEUM',
|
||||
'NATURALSCIENCES.MUSEUM',
|
||||
'NATURE.MUSEUM',
|
||||
'NATURHISTORISCHES.MUSEUM',
|
||||
'NATUURWETENSCHAPPEN.MUSEUM',
|
||||
'NAUMBURG.MUSEUM',
|
||||
'NAVAL.MUSEUM',
|
||||
'NEBRASKA.MUSEUM',
|
||||
'NEUES.MUSEUM',
|
||||
'NEWHAMPSHIRE.MUSEUM',
|
||||
'NEWJERSEY.MUSEUM',
|
||||
'NEWMEXICO.MUSEUM',
|
||||
'NEWPORT.MUSEUM',
|
||||
'NEWSPAPER.MUSEUM',
|
||||
'NEWYORK.MUSEUM',
|
||||
'NIEPCE.MUSEUM',
|
||||
'NORFOLK.MUSEUM',
|
||||
'NORTH.MUSEUM',
|
||||
'NRW.MUSEUM',
|
||||
'NYC.MUSEUM',
|
||||
'NYNY.MUSEUM',
|
||||
'OCEANOGRAPHIC.MUSEUM',
|
||||
'OCEANOGRAPHIQUE.MUSEUM',
|
||||
'OMAHA.MUSEUM',
|
||||
'ONLINE.MUSEUM',
|
||||
'ONTARIO.MUSEUM',
|
||||
'OPENAIR.MUSEUM',
|
||||
'OREGON.MUSEUM',
|
||||
'OREGONTRAIL.MUSEUM',
|
||||
'OTAGO.MUSEUM',
|
||||
'OXFORD.MUSEUM',
|
||||
'PACIFIC.MUSEUM',
|
||||
'PADERBORN.MUSEUM',
|
||||
'PALACE.MUSEUM',
|
||||
'PALEO.MUSEUM',
|
||||
'PALMSPRINGS.MUSEUM',
|
||||
'PANAMA.MUSEUM',
|
||||
'PARIS.MUSEUM',
|
||||
'PASADENA.MUSEUM',
|
||||
'PHARMACY.MUSEUM',
|
||||
'PHILADELPHIA.MUSEUM',
|
||||
'PHILADELPHIAAREA.MUSEUM',
|
||||
'PHILATELY.MUSEUM',
|
||||
'PHOENIX.MUSEUM',
|
||||
'PHOTOGRAPHY.MUSEUM',
|
||||
'PILOTS.MUSEUM',
|
||||
'PITTSBURGH.MUSEUM',
|
||||
'PLANETARIUM.MUSEUM',
|
||||
'PLANTATION.MUSEUM',
|
||||
'PLANTS.MUSEUM',
|
||||
'PLAZA.MUSEUM',
|
||||
'PORTAL.MUSEUM',
|
||||
'PORTLAND.MUSEUM',
|
||||
'PORTLLIGAT.MUSEUM',
|
||||
'POSTS-AND-TELECOMMUNICATIONS.MUSEUM',
|
||||
'PRESERVATION.MUSEUM',
|
||||
'PRESIDIO.MUSEUM',
|
||||
'PRESS.MUSEUM',
|
||||
'PROJECT.MUSEUM',
|
||||
'PUBLIC.MUSEUM',
|
||||
'PUBOL.MUSEUM',
|
||||
'QUEBEC.MUSEUM',
|
||||
'RAILROAD.MUSEUM',
|
||||
'RAILWAY.MUSEUM',
|
||||
'RESEARCH.MUSEUM',
|
||||
'RESISTANCE.MUSEUM',
|
||||
'RIODEJANEIRO.MUSEUM',
|
||||
'ROCHESTER.MUSEUM',
|
||||
'ROCKART.MUSEUM',
|
||||
'ROMA.MUSEUM',
|
||||
'RUSSIA.MUSEUM',
|
||||
'SAINTLOUIS.MUSEUM',
|
||||
'SALEM.MUSEUM',
|
||||
'SALVADORDALI.MUSEUM',
|
||||
'SALZBURG.MUSEUM',
|
||||
'SANDIEGO.MUSEUM',
|
||||
'SANFRANCISCO.MUSEUM',
|
||||
'SANTABARBARA.MUSEUM',
|
||||
'SANTACRUZ.MUSEUM',
|
||||
'SANTAFE.MUSEUM',
|
||||
'SASKATCHEWAN.MUSEUM',
|
||||
'SATX.MUSEUM',
|
||||
'SAVANNAHGA.MUSEUM',
|
||||
'SCHLESISCHES.MUSEUM',
|
||||
'SCHOENBRUNN.MUSEUM',
|
||||
'SCHOKOLADEN.MUSEUM',
|
||||
'SCHOOL.MUSEUM',
|
||||
'SCHWEIZ.MUSEUM',
|
||||
'SCIENCE-FICTION.MUSEUM',
|
||||
'SCIENCE.MUSEUM',
|
||||
'SCIENCEANDHISTORY.MUSEUM',
|
||||
'SCIENCEANDINDUSTRY.MUSEUM',
|
||||
'SCIENCECENTER.MUSEUM',
|
||||
'SCIENCECENTERS.MUSEUM',
|
||||
'SCIENCEHISTORY.MUSEUM',
|
||||
'SCIENCES.MUSEUM',
|
||||
'SCIENCESNATURELLES.MUSEUM',
|
||||
'SCOTLAND.MUSEUM',
|
||||
'SEAPORT.MUSEUM',
|
||||
'SETTLEMENT.MUSEUM',
|
||||
'SETTLERS.MUSEUM',
|
||||
'SHELL.MUSEUM',
|
||||
'SHERBROOKE.MUSEUM',
|
||||
'SIBENIK.MUSEUM',
|
||||
'SILK.MUSEUM',
|
||||
'SKI.MUSEUM',
|
||||
'SKOLE.MUSEUM',
|
||||
'SOCIETY.MUSEUM',
|
||||
'SOLOGNE.MUSEUM',
|
||||
'SOUNDANDVISION.MUSEUM',
|
||||
'SOUTHCAROLINA.MUSEUM',
|
||||
'SOUTHWEST.MUSEUM',
|
||||
'SPACE.MUSEUM',
|
||||
'SPY.MUSEUM',
|
||||
'SQUARE.MUSEUM',
|
||||
'STADT.MUSEUM',
|
||||
'STALBANS.MUSEUM',
|
||||
'STARNBERG.MUSEUM',
|
||||
'STATE.MUSEUM',
|
||||
'STATEOFDELAWARE.MUSEUM',
|
||||
'STATION.MUSEUM',
|
||||
'STEAM.MUSEUM',
|
||||
'STEIERMARK.MUSEUM',
|
||||
'STJOHN.MUSEUM',
|
||||
'STOCKHOLM.MUSEUM',
|
||||
'STPETERSBURG.MUSEUM',
|
||||
'STUTTGART.MUSEUM',
|
||||
'SUISSE.MUSEUM',
|
||||
'SURGEONSHALL.MUSEUM',
|
||||
'SURREY.MUSEUM',
|
||||
'SVIZZERA.MUSEUM',
|
||||
'SWEDEN.MUSEUM',
|
||||
'SYDNEY.MUSEUM',
|
||||
'TANK.MUSEUM',
|
||||
'TCM.MUSEUM',
|
||||
'TECHNOLOGY.MUSEUM',
|
||||
'TELEKOMMUNIKATION.MUSEUM',
|
||||
'TELEVISION.MUSEUM',
|
||||
'TEXAS.MUSEUM',
|
||||
'TEXTILE.MUSEUM',
|
||||
'THEATER.MUSEUM',
|
||||
'TIME.MUSEUM',
|
||||
'TIMEKEEPING.MUSEUM',
|
||||
'TOPOLOGY.MUSEUM',
|
||||
'TORINO.MUSEUM',
|
||||
'TOUCH.MUSEUM',
|
||||
'TOWN.MUSEUM',
|
||||
'TRANSPORT.MUSEUM',
|
||||
'TREE.MUSEUM',
|
||||
'TROLLEY.MUSEUM',
|
||||
'TRUST.MUSEUM',
|
||||
'TRUSTEE.MUSEUM',
|
||||
'UHREN.MUSEUM',
|
||||
'ULM.MUSEUM',
|
||||
'UNDERSEA.MUSEUM',
|
||||
'UNIVERSITY.MUSEUM',
|
||||
'USA.MUSEUM',
|
||||
'USANTIQUES.MUSEUM',
|
||||
'USARTS.MUSEUM',
|
||||
'USCOUNTRYESTATE.MUSEUM',
|
||||
'USCULTURE.MUSEUM',
|
||||
'USDECORATIVEARTS.MUSEUM',
|
||||
'USGARDEN.MUSEUM',
|
||||
'USHISTORY.MUSEUM',
|
||||
'USHUAIA.MUSEUM',
|
||||
'USLIVINGHISTORY.MUSEUM',
|
||||
'UTAH.MUSEUM',
|
||||
'UVIC.MUSEUM',
|
||||
'VALLEY.MUSEUM',
|
||||
'VANTAA.MUSEUM',
|
||||
'VERSAILLES.MUSEUM',
|
||||
'VIKING.MUSEUM',
|
||||
'VILLAGE.MUSEUM',
|
||||
'VIRGINIA.MUSEUM',
|
||||
'VIRTUAL.MUSEUM',
|
||||
'VIRTUEL.MUSEUM',
|
||||
'VLAANDEREN.MUSEUM',
|
||||
'VOLKENKUNDE.MUSEUM',
|
||||
'WALES.MUSEUM',
|
||||
'WALLONIE.MUSEUM',
|
||||
'WAR.MUSEUM',
|
||||
'WASHINGTONDC.MUSEUM',
|
||||
'WATCH-AND-CLOCK.MUSEUM',
|
||||
'WATCHANDCLOCK.MUSEUM',
|
||||
'WESTERN.MUSEUM',
|
||||
'WESTFALEN.MUSEUM',
|
||||
'WHALING.MUSEUM',
|
||||
'WILDLIFE.MUSEUM',
|
||||
'WILLIAMSBURG.MUSEUM',
|
||||
'WINDMILL.MUSEUM',
|
||||
'WORKSHOP.MUSEUM',
|
||||
'XN--9DBHBLG6DI.MUSEUM',
|
||||
'XN--COMUNICAES-V6A2O.MUSEUM',
|
||||
'XN--CORREIOS-E-TELECOMUNICAES-GHC29A.MUSEUM',
|
||||
'XN--H1AEGH.MUSEUM',
|
||||
'XN--LNS-QLA.MUSEUM',
|
||||
'YORK.MUSEUM',
|
||||
'YORKSHIRE.MUSEUM',
|
||||
'YOSEMITE.MUSEUM',
|
||||
'YOUTH.MUSEUM',
|
||||
'ZOOLOGICAL.MUSEUM',
|
||||
'ZOOLOGY.MUSEUM',
|
||||
];
|
|
@ -89,14 +89,18 @@ return [
|
|||
'NOM.PL',
|
||||
'NOWARUDA.PL',
|
||||
'NYSA.PL',
|
||||
'OIA.GOV.PL',
|
||||
'OIRM.GOV.PL',
|
||||
'OKE.GOV.PL',
|
||||
'OLAWA.PL',
|
||||
'OLECKO.PL',
|
||||
'OLKUSZ.PL',
|
||||
'OLSZTYN.PL',
|
||||
'OOW.GOV.PL',
|
||||
'OPOCZNO.PL',
|
||||
'OPOLE.PL',
|
||||
'ORG.PL',
|
||||
'OSCHR.GOV.PL',
|
||||
'OSTRODA.PL',
|
||||
'OSTROLEKA.PL',
|
||||
'OSTROWIEC.PL',
|
||||
|
@ -115,6 +119,7 @@ return [
|
|||
'POMORSKIE.PL',
|
||||
'POMORZE.PL',
|
||||
'POWIAT.PL',
|
||||
'PR.GOV.PL',
|
||||
'PRIV.PL',
|
||||
'PROCHOWICE.PL',
|
||||
'PRUSZKOW.PL',
|
||||
|
@ -187,6 +192,7 @@ return [
|
|||
'WIOS.GOV.PL',
|
||||
'WITD.GOV.PL',
|
||||
'WIW.GOV.PL',
|
||||
'WKZ.GOV.PL',
|
||||
'WLOCL.PL',
|
||||
'WLOCLAWEK.PL',
|
||||
'WODZISLAW.PL',
|
||||
|
@ -194,6 +200,7 @@ return [
|
|||
'WROCLAW.PL',
|
||||
'WSA.GOV.PL',
|
||||
'WSKR.GOV.PL',
|
||||
'WSSE.GOV.PL',
|
||||
'WUOZ.GOV.PL',
|
||||
'WZMIUW.GOV.PL',
|
||||
'ZACHPOMOR.PL',
|
||||
|
@ -202,4 +209,5 @@ return [
|
|||
'ZGORA.PL',
|
||||
'ZGORZELEC.PL',
|
||||
'ZP.GOV.PL',
|
||||
'ZPISDN.GOV.PL',
|
||||
];
|
||||
|
|
|
@ -34,6 +34,7 @@ return [
|
|||
'KIROVOGRAD.UA',
|
||||
'KM.UA',
|
||||
'KR.UA',
|
||||
'KROPYVNYTSKYI.UA',
|
||||
'KRYM.UA',
|
||||
'KS.UA',
|
||||
'KV.UA',
|
||||
|
|
|
@ -7,4 +7,4 @@ you can install it using [Composer](http://getcomposer.org).
|
|||
composer require respect/validation
|
||||
```
|
||||
|
||||
Works on PHP 7.3 or above.
|
||||
Works on PHP 8.1 or above.
|
||||
|
|
|
@ -46,8 +46,6 @@ interface ChainedValidator extends Validatable
|
|||
*/
|
||||
public function between($minimum, $maximum): ChainedValidator;
|
||||
|
||||
public function bic(string $countryCode): ChainedValidator;
|
||||
|
||||
public function boolType(): ChainedValidator;
|
||||
|
||||
public function boolVal(): ChainedValidator;
|
||||
|
@ -294,6 +292,8 @@ interface ChainedValidator extends Validatable
|
|||
|
||||
public function polishIdCard(): ChainedValidator;
|
||||
|
||||
public function portugueseNif(): ChainedValidator;
|
||||
|
||||
public function positive(): ChainedValidator;
|
||||
|
||||
public function postalCode(string $countryCode): ChainedValidator;
|
||||
|
@ -302,6 +302,8 @@ interface ChainedValidator extends Validatable
|
|||
|
||||
public function printable(string ...$additionalChars): ChainedValidator;
|
||||
|
||||
public function publicDomainSuffix(): ChainedValidator;
|
||||
|
||||
public function punct(string ...$additionalChars): ChainedValidator;
|
||||
|
||||
public function readable(): ChainedValidator;
|
||||
|
|
|
@ -20,10 +20,10 @@ final class ExistsException extends ValidationException
|
|||
*/
|
||||
protected $defaultTemplates = [
|
||||
self::MODE_DEFAULT => [
|
||||
self::STANDARD => '{{name}} must exists',
|
||||
self::STANDARD => '{{name}} must exist',
|
||||
],
|
||||
self::MODE_NEGATIVE => [
|
||||
self::STANDARD => '{{name}} must not exists',
|
||||
self::STANDARD => '{{name}} must not exist',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ final class FalseValException extends ValidationException
|
|||
*/
|
||||
protected $defaultTemplates = [
|
||||
self::MODE_DEFAULT => [
|
||||
self::STANDARD => '{{name}} is not considered as "False"',
|
||||
self::STANDARD => '{{name}} must evaluate to `false`',
|
||||
],
|
||||
self::MODE_NEGATIVE => [
|
||||
self::STANDARD => '{{name}} is considered as "False"',
|
||||
self::STANDARD => '{{name}} must not evaluate to `false`',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ final class NoException extends ValidationException
|
|||
*/
|
||||
protected $defaultTemplates = [
|
||||
self::MODE_DEFAULT => [
|
||||
self::STANDARD => '{{name}} is not considered as "No"',
|
||||
self::STANDARD => '{{name}} must be similar to "No"',
|
||||
],
|
||||
self::MODE_NEGATIVE => [
|
||||
self::STANDARD => '{{name}} is considered as "No"',
|
||||
self::STANDARD => '{{name}} must not be similar to "No"',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ final class TrueValException extends ValidationException
|
|||
*/
|
||||
protected $defaultTemplates = [
|
||||
self::MODE_DEFAULT => [
|
||||
self::STANDARD => '{{name}} is not considered as "True"',
|
||||
self::STANDARD => '{{name}} must evaluate to `true`',
|
||||
],
|
||||
self::MODE_NEGATIVE => [
|
||||
self::STANDARD => '{{name}} is considered as "True"',
|
||||
self::STANDARD => '{{name}} must not evaluate to `true`',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ final class YesException extends ValidationException
|
|||
*/
|
||||
protected $defaultTemplates = [
|
||||
self::MODE_DEFAULT => [
|
||||
self::STANDARD => '{{name}} is not considered as "Yes"',
|
||||
self::STANDARD => '{{name}} must be similar to "Yes"',
|
||||
],
|
||||
self::MODE_NEGATIVE => [
|
||||
self::STANDARD => '{{name}} is considered as "Yes"',
|
||||
self::STANDARD => '{{name}} must not be similar to "Yes"',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use function is_object;
|
|||
use function property_exists;
|
||||
|
||||
/**
|
||||
* Validates an object attribute, event private ones.
|
||||
* Validates an object attribute, even private ones.
|
||||
*
|
||||
* @author Alexandre Gomes Gaigalas <alganet@gmail.com>
|
||||
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
|
||||
|
@ -38,7 +38,9 @@ final class Attribute extends AbstractRelated
|
|||
public function getReferenceValue($input)
|
||||
{
|
||||
$propertyMirror = new ReflectionProperty($input, (string) $this->getReference());
|
||||
$propertyMirror->setAccessible(true);
|
||||
if ($propertyMirror->isInitialized($input) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $propertyMirror->getValue($input);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ final class CurrencyCode extends AbstractSearcher
|
|||
* @see http://www.currency-iso.org/en/home/tables/table-a1.html
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getDataSource($input = null): array
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ use function function_exists;
|
|||
use function is_string;
|
||||
use function json_decode;
|
||||
use function json_last_error;
|
||||
use function json_validate;
|
||||
|
||||
use const JSON_ERROR_NONE;
|
||||
|
||||
|
|
|
@ -27,25 +27,25 @@ final class Tld extends AbstractRule
|
|||
* List extracted from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
|
||||
*/
|
||||
private const TLD_LIST = [
|
||||
'AAA', 'AARP', 'ABARTH', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE',
|
||||
'ABOGADO', 'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT',
|
||||
'ACCOUNTANTS', 'ACO', 'ACTOR', 'AD', 'ADS', 'ADULT', 'AE', 'AEG',
|
||||
'AERO', 'AETNA', 'AF', 'AFL', 'AFRICA', 'AG', 'AGAKHAN', 'AGENCY',
|
||||
'AI', 'AIG', 'AIRBUS', 'AIRFORCE', 'AIRTEL', 'AKDN', 'AL', 'ALFAROMEO',
|
||||
'ALIBABA', 'ALIPAY', 'ALLFINANZ', 'ALLSTATE', 'ALLY', 'ALSACE',
|
||||
'ALSTOM', 'AM', 'AMAZON', 'AMERICANEXPRESS', 'AMERICANFAMILY', 'AMEX',
|
||||
'AMFAM', 'AMICA', 'AMSTERDAM', 'ANALYTICS', 'ANDROID', 'ANQUAN', 'ANZ',
|
||||
'AO', 'AOL', 'APARTMENTS', 'APP', 'APPLE', 'AQ', 'AQUARELLE', 'AR',
|
||||
'ARAB', 'ARAMCO', 'ARCHI', 'ARMY', 'ARPA', 'ART', 'ARTE', 'AS', 'ASDA',
|
||||
'ASIA', 'ASSOCIATES', 'AT', 'ATHLETA', 'ATTORNEY', 'AU', 'AUCTION',
|
||||
'AUDI', 'AUDIBLE', 'AUDIO', 'AUSPOST', 'AUTHOR', 'AUTO', 'AUTOS',
|
||||
'AVIANCA', 'AW', 'AWS', 'AX', 'AXA', 'AZ', 'AZURE', 'BA', 'BABY',
|
||||
'BAIDU', 'BANAMEX', 'BANANAREPUBLIC', 'BAND', 'BANK', 'BAR',
|
||||
'BARCELONA', 'BARCLAYCARD', 'BARCLAYS', 'BAREFOOT', 'BARGAINS',
|
||||
'BASEBALL', 'BASKETBALL', 'BAUHAUS', 'BAYERN', 'BB', 'BBC', 'BBT',
|
||||
'BBVA', 'BCG', 'BCN', 'BD', 'BE', 'BEATS', 'BEAUTY', 'BEER', 'BENTLEY',
|
||||
'BERLIN', 'BEST', 'BESTBUY', 'BET', 'BF', 'BG', 'BH', 'BHARTI', 'BI',
|
||||
'BIBLE', 'BID', 'BIKE', 'BING', 'BINGO', 'BIO', 'BIZ', 'BJ', 'BLACK',
|
||||
'AAA', 'AARP', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE', 'ABOGADO',
|
||||
'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT', 'ACCOUNTANTS',
|
||||
'ACO', 'ACTOR', 'AD', 'ADS', 'ADULT', 'AE', 'AEG', 'AERO', 'AETNA',
|
||||
'AF', 'AFL', 'AFRICA', 'AG', 'AGAKHAN', 'AGENCY', 'AI', 'AIG',
|
||||
'AIRBUS', 'AIRFORCE', 'AIRTEL', 'AKDN', 'AL', 'ALIBABA', 'ALIPAY',
|
||||
'ALLFINANZ', 'ALLSTATE', 'ALLY', 'ALSACE', 'ALSTOM', 'AM', 'AMAZON',
|
||||
'AMERICANEXPRESS', 'AMERICANFAMILY', 'AMEX', 'AMFAM', 'AMICA',
|
||||
'AMSTERDAM', 'ANALYTICS', 'ANDROID', 'ANQUAN', 'ANZ', 'AO', 'AOL',
|
||||
'APARTMENTS', 'APP', 'APPLE', 'AQ', 'AQUARELLE', 'AR', 'ARAB',
|
||||
'ARAMCO', 'ARCHI', 'ARMY', 'ARPA', 'ART', 'ARTE', 'AS', 'ASDA', 'ASIA',
|
||||
'ASSOCIATES', 'AT', 'ATHLETA', 'ATTORNEY', 'AU', 'AUCTION', 'AUDI',
|
||||
'AUDIBLE', 'AUDIO', 'AUSPOST', 'AUTHOR', 'AUTO', 'AUTOS', 'AVIANCA',
|
||||
'AW', 'AWS', 'AX', 'AXA', 'AZ', 'AZURE', 'BA', 'BABY', 'BAIDU',
|
||||
'BANAMEX', 'BANANAREPUBLIC', 'BAND', 'BANK', 'BAR', 'BARCELONA',
|
||||
'BARCLAYCARD', 'BARCLAYS', 'BAREFOOT', 'BARGAINS', 'BASEBALL',
|
||||
'BASKETBALL', 'BAUHAUS', 'BAYERN', 'BB', 'BBC', 'BBT', 'BBVA', 'BCG',
|
||||
'BCN', 'BD', 'BE', 'BEATS', 'BEAUTY', 'BEER', 'BENTLEY', 'BERLIN',
|
||||
'BEST', 'BESTBUY', 'BET', 'BF', 'BG', 'BH', 'BHARTI', 'BI', 'BIBLE',
|
||||
'BID', 'BIKE', 'BING', 'BINGO', 'BIO', 'BIZ', 'BJ', 'BLACK',
|
||||
'BLACKFRIDAY', 'BLOCKBUSTER', 'BLOG', 'BLOOMBERG', 'BLUE', 'BM', 'BMS',
|
||||
'BMW', 'BN', 'BNPPARIBAS', 'BO', 'BOATS', 'BOEHRINGER', 'BOFA', 'BOM',
|
||||
'BOND', 'BOO', 'BOOK', 'BOOKING', 'BOSCH', 'BOSTIK', 'BOSTON', 'BOT',
|
||||
|
@ -82,11 +82,11 @@ final class Tld extends AbstractRule
|
|||
'EUROVISION', 'EUS', 'EVENTS', 'EXCHANGE', 'EXPERT', 'EXPOSED',
|
||||
'EXPRESS', 'EXTRASPACE', 'FAGE', 'FAIL', 'FAIRWINDS', 'FAITH',
|
||||
'FAMILY', 'FAN', 'FANS', 'FARM', 'FARMERS', 'FASHION', 'FAST', 'FEDEX',
|
||||
'FEEDBACK', 'FERRARI', 'FERRERO', 'FI', 'FIAT', 'FIDELITY', 'FIDO',
|
||||
'FILM', 'FINAL', 'FINANCE', 'FINANCIAL', 'FIRE', 'FIRESTONE',
|
||||
'FIRMDALE', 'FISH', 'FISHING', 'FIT', 'FITNESS', 'FJ', 'FK', 'FLICKR',
|
||||
'FLIGHTS', 'FLIR', 'FLORIST', 'FLOWERS', 'FLY', 'FM', 'FO', 'FOO',
|
||||
'FOOD', 'FOODNETWORK', 'FOOTBALL', 'FORD', 'FOREX', 'FORSALE', 'FORUM',
|
||||
'FEEDBACK', 'FERRARI', 'FERRERO', 'FI', 'FIDELITY', 'FIDO', 'FILM',
|
||||
'FINAL', 'FINANCE', 'FINANCIAL', 'FIRE', 'FIRESTONE', 'FIRMDALE',
|
||||
'FISH', 'FISHING', 'FIT', 'FITNESS', 'FJ', 'FK', 'FLICKR', 'FLIGHTS',
|
||||
'FLIR', 'FLORIST', 'FLOWERS', 'FLY', 'FM', 'FO', 'FOO', 'FOOD',
|
||||
'FOODNETWORK', 'FOOTBALL', 'FORD', 'FOREX', 'FORSALE', 'FORUM',
|
||||
'FOUNDATION', 'FOX', 'FR', 'FREE', 'FRESENIUS', 'FRL', 'FROGANS',
|
||||
'FRONTDOOR', 'FRONTIER', 'FTR', 'FUJITSU', 'FUN', 'FUND', 'FURNITURE',
|
||||
'FUTBOL', 'FYI', 'GA', 'GAL', 'GALLERY', 'GALLO', 'GALLUP', 'GAME',
|
||||
|
@ -117,18 +117,17 @@ final class Tld extends AbstractRule
|
|||
'KINDER', 'KINDLE', 'KITCHEN', 'KIWI', 'KM', 'KN', 'KOELN', 'KOMATSU',
|
||||
'KOSHER', 'KP', 'KPMG', 'KPN', 'KR', 'KRD', 'KRED', 'KUOKGROUP', 'KW',
|
||||
'KY', 'KYOTO', 'KZ', 'LA', 'LACAIXA', 'LAMBORGHINI', 'LAMER',
|
||||
'LANCASTER', 'LANCIA', 'LAND', 'LANDROVER', 'LANXESS', 'LASALLE',
|
||||
'LAT', 'LATINO', 'LATROBE', 'LAW', 'LAWYER', 'LB', 'LC', 'LDS',
|
||||
'LEASE', 'LECLERC', 'LEFRAK', 'LEGAL', 'LEGO', 'LEXUS', 'LGBT', 'LI',
|
||||
'LIDL', 'LIFE', 'LIFEINSURANCE', 'LIFESTYLE', 'LIGHTING', 'LIKE',
|
||||
'LILLY', 'LIMITED', 'LIMO', 'LINCOLN', 'LINDE', 'LINK', 'LIPSY',
|
||||
'LIVE', 'LIVING', 'LK', 'LLC', 'LLP', 'LOAN', 'LOANS', 'LOCKER',
|
||||
'LOCUS', 'LOL', 'LONDON', 'LOTTE', 'LOTTO', 'LOVE', 'LPL',
|
||||
'LPLFINANCIAL', 'LR', 'LS', 'LT', 'LTD', 'LTDA', 'LU', 'LUNDBECK',
|
||||
'LUXE', 'LUXURY', 'LV', 'LY', 'MA', 'MACYS', 'MADRID', 'MAIF',
|
||||
'MAISON', 'MAKEUP', 'MAN', 'MANAGEMENT', 'MANGO', 'MAP', 'MARKET',
|
||||
'MARKETING', 'MARKETS', 'MARRIOTT', 'MARSHALLS', 'MASERATI', 'MATTEL',
|
||||
'MBA', 'MC', 'MCKINSEY', 'MD', 'ME', 'MED', 'MEDIA', 'MEET',
|
||||
'LANCASTER', 'LAND', 'LANDROVER', 'LANXESS', 'LASALLE', 'LAT',
|
||||
'LATINO', 'LATROBE', 'LAW', 'LAWYER', 'LB', 'LC', 'LDS', 'LEASE',
|
||||
'LECLERC', 'LEFRAK', 'LEGAL', 'LEGO', 'LEXUS', 'LGBT', 'LI', 'LIDL',
|
||||
'LIFE', 'LIFEINSURANCE', 'LIFESTYLE', 'LIGHTING', 'LIKE', 'LILLY',
|
||||
'LIMITED', 'LIMO', 'LINCOLN', 'LINK', 'LIPSY', 'LIVE', 'LIVING', 'LK',
|
||||
'LLC', 'LLP', 'LOAN', 'LOANS', 'LOCKER', 'LOCUS', 'LOL', 'LONDON',
|
||||
'LOTTE', 'LOTTO', 'LOVE', 'LPL', 'LPLFINANCIAL', 'LR', 'LS', 'LT',
|
||||
'LTD', 'LTDA', 'LU', 'LUNDBECK', 'LUXE', 'LUXURY', 'LV', 'LY', 'MA',
|
||||
'MADRID', 'MAIF', 'MAISON', 'MAKEUP', 'MAN', 'MANAGEMENT', 'MANGO',
|
||||
'MAP', 'MARKET', 'MARKETING', 'MARKETS', 'MARRIOTT', 'MARSHALLS',
|
||||
'MATTEL', 'MBA', 'MC', 'MCKINSEY', 'MD', 'ME', 'MED', 'MEDIA', 'MEET',
|
||||
'MELBOURNE', 'MEME', 'MEMORIAL', 'MEN', 'MENU', 'MERCKMSD', 'MG', 'MH',
|
||||
'MIAMI', 'MICROSOFT', 'MIL', 'MINI', 'MINT', 'MIT', 'MITSUBISHI', 'MK',
|
||||
'ML', 'MLB', 'MLS', 'MM', 'MMA', 'MN', 'MO', 'MOBI', 'MOBILE', 'MODA',
|
||||
|
|
|
@ -14,5 +14,14 @@
|
|||
<file>library/</file>
|
||||
<file>tests/</file>
|
||||
|
||||
<rule ref="Respect" />
|
||||
<rule ref="Respect">
|
||||
<exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden" />
|
||||
<exclude name="SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment" />
|
||||
<exclude name="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion.RequiredConstructorPropertyPromotion" />
|
||||
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint" />
|
||||
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint" />
|
||||
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint" />
|
||||
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint" />
|
||||
<exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall" />
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
|
|
@ -25,7 +25,14 @@ parameters:
|
|||
# Why: StaticValidator is a stub interface that types __callStatic
|
||||
message: '/Call to static method PHPUnit\\Framework\\Assert::assertSame\(\) with Respect\\Validation\\Validator and Respect\\Validation\\ChainedValidator will always evaluate to false./'
|
||||
path: tests/unit/ValidatorTest.php
|
||||
|
||||
-
|
||||
# Why: I don't want to make changes to the code just to make phpstan happy
|
||||
message: '/Parameter #2 \$values of function vsprintf expects array<bool\|float\|int\|string\|null>, array<string, array<bool\|int\|string>\|bool\|float\|int\|string> given./'
|
||||
path: library/Rules/AbstractAge.php
|
||||
level: 8
|
||||
paths:
|
||||
- library/
|
||||
- tests/
|
||||
excludePaths:
|
||||
- tests/integration/
|
||||
|
|
|
@ -8,10 +8,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
exceptionFullMessage(static function () {
|
||||
$array = [
|
||||
'mysql' => [
|
||||
'host' => 42,
|
||||
|
@ -48,9 +47,7 @@ try {
|
|||
)
|
||||
->setName('the given data')
|
||||
->assert($object);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
- All of the required rules must pass for the given data
|
||||
|
|
|
@ -7,10 +7,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
exceptionFullMessage(static function () {
|
||||
v::create()
|
||||
->key(
|
||||
'mysql',
|
||||
|
@ -41,9 +40,7 @@ try {
|
|||
'password' => 42,
|
||||
],
|
||||
]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
- All of the required rules must pass for the given data
|
||||
|
|
|
@ -9,14 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
try {
|
||||
Validator::stringType()->length(2, 15)->assert(0);
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
exceptionFullMessage(static fn() => Validator::stringType()->length(2, 15)->assert(0));
|
||||
?>
|
||||
--EXPECT--
|
||||
- All of the required rules must pass for 0
|
||||
|
|
|
@ -7,10 +7,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
exceptionMessages(static function () {
|
||||
v::create()
|
||||
->key(
|
||||
'mysql',
|
||||
|
@ -40,9 +39,7 @@ try {
|
|||
'password' => 42,
|
||||
],
|
||||
]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
print_r($exception->getMessages());
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
|
|
|
@ -11,10 +11,9 @@ date_default_timezone_set('UTC');
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
try {
|
||||
exceptionMessages(static function () {
|
||||
$input = [
|
||||
'username' => 'u',
|
||||
'birthdate' => 'Not a date',
|
||||
|
@ -27,9 +26,7 @@ try {
|
|||
->key('password', Validator::notEmpty())
|
||||
->key('email', Validator::email())
|
||||
->assert($input);
|
||||
} catch (NestedValidationException $e) {
|
||||
print_r($e->getMessages());
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
|
|
|
@ -8,41 +8,41 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::create()
|
||||
->key(
|
||||
'mysql',
|
||||
v::create()
|
||||
->key('host', v::stringType(), true)
|
||||
->key('user', v::stringType(), true)
|
||||
->key('password', v::stringType(), true)
|
||||
->key('schema', v::stringType(), true),
|
||||
true
|
||||
)
|
||||
->key(
|
||||
'postgresql',
|
||||
v::create()
|
||||
->key('host', v::stringType(), true)
|
||||
->key('user', v::stringType(), true)
|
||||
->key('password', v::stringType(), true)
|
||||
->key('schema', v::stringType(), true),
|
||||
true
|
||||
)
|
||||
->assert([
|
||||
'mysql' => [
|
||||
'host' => 42,
|
||||
'schema' => 42,
|
||||
],
|
||||
'postgresql' => [
|
||||
'user' => 42,
|
||||
'password' => 42,
|
||||
],
|
||||
]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
print_r($exception->getMessages([
|
||||
exceptionMessages(
|
||||
static function () {
|
||||
v::create()
|
||||
->key(
|
||||
'mysql',
|
||||
v::create()
|
||||
->key('host', v::stringType(), true)
|
||||
->key('user', v::stringType(), true)
|
||||
->key('password', v::stringType(), true)
|
||||
->key('schema', v::stringType(), true),
|
||||
true
|
||||
)
|
||||
->key(
|
||||
'postgresql',
|
||||
v::create()
|
||||
->key('host', v::stringType(), true)
|
||||
->key('user', v::stringType(), true)
|
||||
->key('password', v::stringType(), true)
|
||||
->key('schema', v::stringType(), true),
|
||||
true
|
||||
)
|
||||
->assert([
|
||||
'mysql' => [
|
||||
'host' => 42,
|
||||
'schema' => 42,
|
||||
],
|
||||
'postgresql' => [
|
||||
'user' => 42,
|
||||
'password' => 42,
|
||||
],
|
||||
]);
|
||||
},
|
||||
[
|
||||
'mysql' => [
|
||||
'user' => 'Value should be a MySQL username',
|
||||
'host' => '{{input}} should be a MySQL host',
|
||||
|
@ -50,8 +50,8 @@ try {
|
|||
'postgresql' => [
|
||||
'schema' => 'You must provide a valid PostgreSQL schema',
|
||||
],
|
||||
]));
|
||||
}
|
||||
]
|
||||
);
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
|
|
|
@ -15,14 +15,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::each(v::equals(1))->assert(['A', 'B', 'B']);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionFullMessage(static fn() => v::each(v::equals(1))->assert(['A', 'B', 'B']));
|
||||
?>
|
||||
--EXPECT--
|
||||
- Each item in `{ "A", "B", "B" }` must be valid
|
||||
|
|
|
@ -5,15 +5,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::key('firstname', v::notBlank()->setName('First Name'))->assert([]);
|
||||
} catch (NestedValidationException $e) {
|
||||
print_r($e->getMessages());
|
||||
}
|
||||
|
||||
exceptionMessages(static fn () => v::key('firstname', v::notBlank()->setName('First Name'))->assert([]));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Array
|
||||
|
|
|
@ -10,8 +10,6 @@ default must be of type string
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Rules\ArrayType;
|
||||
use Respect\Validation\Rules\BoolType;
|
||||
use Respect\Validation\Rules\Each;
|
||||
|
@ -55,17 +53,8 @@ $input = [
|
|||
'children' => ['nope'],
|
||||
],
|
||||
];
|
||||
try {
|
||||
$validator->check($input);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
$validator->assert($input);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage();
|
||||
}
|
||||
exceptionMessage(static fn() => $validator->check($input));
|
||||
exceptionFullMessage(static fn() => $validator->assert($input));
|
||||
?>
|
||||
--EXPECT--
|
||||
default must be of type string
|
||||
|
|
|
@ -7,17 +7,16 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
$cars = [
|
||||
['manufacturer' => 'Honda', 'model' => 'Accord'],
|
||||
['manufacturer' => 'Toyota', 'model' => 'Rav4'],
|
||||
['manufacturer' => 'Ford', 'model' => 'notarealcar'],
|
||||
['manufacturer' => 'Ford', 'model' => 'not real'],
|
||||
['manufacturer' => 'Honda', 'model' => 'not valid'],
|
||||
];
|
||||
|
||||
try {
|
||||
exceptionMessages(static function () use ($cars) {
|
||||
Validator::arrayType()->each(
|
||||
Validator::oneOf(
|
||||
Validator::key('manufacturer', Validator::equals('Honda'))
|
||||
|
@ -28,19 +27,15 @@ try {
|
|||
->key('model', Validator::in(['F150', 'Bronco']))
|
||||
)
|
||||
)->assert($cars);
|
||||
} catch (NestedValidationException $e) {
|
||||
var_dump($e->getMessages());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["each"]=>
|
||||
array(2) {
|
||||
["validator.0"]=>
|
||||
string(92) "All of the required rules must pass for `{ "manufacturer": "Ford", "model": "notarealcar" }`"
|
||||
["validator.1"]=>
|
||||
string(91) "All of the required rules must pass for `{ "manufacturer": "Honda", "model": "not valid" }`"
|
||||
}
|
||||
}
|
||||
Array
|
||||
(
|
||||
[each] => Array
|
||||
(
|
||||
[validator.0] => All of the required rules must pass for `{ "manufacturer": "Ford", "model": "not real" }`
|
||||
[validator.1] => All of the required rules must pass for `{ "manufacturer": "Honda", "model": "not valid" }`
|
||||
)
|
||||
|
||||
)
|
||||
|
|
|
@ -7,7 +7,6 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$config = [
|
||||
|
@ -23,11 +22,7 @@ $validator->key('user', v::stringType());
|
|||
$validator->key('password', v::stringType());
|
||||
$validator->key('schema', v::stringType());
|
||||
|
||||
try {
|
||||
$validator->assert($config);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionFullMessage(static fn() => $validator->assert($config));
|
||||
?>
|
||||
--EXPECT--
|
||||
- These rules must pass for Settings
|
||||
|
|
|
@ -7,26 +7,14 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$validator = v::create()
|
||||
->key('age', v::intType()->notEmpty()->noneOf(v::stringType()))
|
||||
->key('reference', v::stringType()->notEmpty()->length(1, 50));
|
||||
|
||||
try {
|
||||
$validator->assert(['age' => 1]);
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
try {
|
||||
$validator->assert(['reference' => 'QSF1234']);
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
exceptionFullMessage(static fn() => $validator->assert(['age' => 1]));
|
||||
exceptionFullMessage(static fn() => $validator->assert(['reference' => 'QSF1234']));
|
||||
?>
|
||||
--EXPECT--
|
||||
- These rules must pass for `{ "age": 1 }`
|
||||
|
|
|
@ -7,7 +7,6 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$arr = [
|
||||
|
@ -15,14 +14,12 @@ $arr = [
|
|||
'email' => 'hello@hello.com',
|
||||
];
|
||||
|
||||
try {
|
||||
exceptionMessages(static function () use ($arr) {
|
||||
v::create()
|
||||
->key('name', v::length(2, 32))
|
||||
->key('email', v::email())
|
||||
->assert($arr);
|
||||
} catch (NestedValidationException $e) {
|
||||
print_r($e->getMessages());
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
|
|
|
@ -8,14 +8,11 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Rules\Instance;
|
||||
|
||||
try {
|
||||
exceptionMessage(static function () {
|
||||
(new Instance('stdClass'))->setTemplate('invalid object')->assert('test');
|
||||
} catch (ValidationException $exception) {
|
||||
print_r($exception->getMessage());
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
invalid object
|
||||
|
|
|
@ -7,7 +7,6 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\PhoneException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$work = new stdClass();
|
||||
|
@ -26,7 +25,7 @@ $phoneNumbers->work = $work;
|
|||
|
||||
$validateThis = ['phoneNumbers' => $phoneNumbers];
|
||||
|
||||
try {
|
||||
exceptionMessage(static function () use ($validateThis) {
|
||||
v::create()
|
||||
->keyNested('phoneNumbers.personal.country', v::intType(), false)
|
||||
->keyNested('phoneNumbers.personal.number', v::phone(), false)
|
||||
|
@ -35,9 +34,7 @@ try {
|
|||
->keyNested('phoneNumbers.work.number', v::phone(), false)
|
||||
->keyNested('phoneNumbers.work.primary', v::boolType(), false)
|
||||
->check($validateThis);
|
||||
} catch (PhoneException $exception) {
|
||||
echo $exception->getMessage();
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
phoneNumbers.personal.number must be a valid telephone number
|
||||
|
|
|
@ -7,14 +7,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::when(v::alwaysInvalid(), v::alwaysValid())->check('foo');
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage();
|
||||
}
|
||||
exceptionMessage(static fn() => v::when(v::alwaysInvalid(), v::alwaysValid())->check('foo'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"foo" is not valid
|
||||
|
|
|
@ -8,10 +8,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
exceptionFullMessage(static function () {
|
||||
v::create()
|
||||
->key(
|
||||
'mysql',
|
||||
|
@ -46,9 +45,7 @@ try {
|
|||
'schema' => 'schema',
|
||||
],
|
||||
]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
- All of the required rules must pass for the given data
|
||||
|
|
|
@ -7,24 +7,21 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Test\Stubs\CountableStub;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$input = 'http://www.google.com/search?q=respect.github.com';
|
||||
|
||||
try {
|
||||
exceptionMessage(static function () use ($input) {
|
||||
v::create()
|
||||
->call(
|
||||
[new CountableStub(1), 'count'],
|
||||
v::arrayVal()->key('scheme', v::startsWith('https'))
|
||||
)
|
||||
->assert($input);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
exceptionMessage(static function () use ($input) {
|
||||
v::create()
|
||||
->call(
|
||||
static function ($url) {
|
||||
|
@ -33,9 +30,7 @@ try {
|
|||
v::arrayVal()->key('scheme', v::startsWith('https'))
|
||||
)
|
||||
->assert($input);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
All of the required rules must pass for "http://www.google.com/search?q=respect.github.com"
|
||||
|
|
|
@ -8,14 +8,11 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
exceptionMessages(static function () {
|
||||
v::key('email', v::email()->setTemplate('WRONG EMAIL!!!!!!'))->assert(['email' => 'qwe']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
print_r($exception->getMessages());
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
Array
|
||||
|
|
|
@ -11,18 +11,15 @@ date_default_timezone_set('UTC');
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
try {
|
||||
exceptionFullMessage(static function () {
|
||||
Validator::create()
|
||||
->key('username', Validator::length(2, 32))
|
||||
->key('birthdate', Validator::dateTime())
|
||||
->setName('User Subscription Form')
|
||||
->assert(['username' => '0', 'birthdate' => 'Whatever']);
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
- All of the required rules must pass for User Subscription Form
|
||||
|
|
41
tests/integration/lib/helpers.php
Normal file
41
tests/integration/lib/helpers.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
|
||||
function exceptionMessage(callable $callable): void
|
||||
{
|
||||
try {
|
||||
$callable();
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, array<string, string>> $templates
|
||||
*/
|
||||
function exceptionMessages(callable $callable, array $templates = []): void
|
||||
{
|
||||
try {
|
||||
$callable();
|
||||
} catch (NestedValidationException $exception) {
|
||||
print_r($exception->getMessages($templates));
|
||||
}
|
||||
}
|
||||
|
||||
function exceptionFullMessage(callable $callable): void
|
||||
{
|
||||
try {
|
||||
$callable();
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ Henrique Moody <henriquemoody@gmail.com>
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
$validator = v::not(
|
||||
|
@ -23,17 +21,8 @@ $validator = v::not(
|
|||
)
|
||||
);
|
||||
|
||||
try {
|
||||
$validator->check(2);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
$validator->assert(2);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => $validator->check(2));
|
||||
exceptionFullMessage(static fn() => $validator->assert(2));
|
||||
?>
|
||||
--EXPECT--
|
||||
2 must not be positive
|
||||
|
|
|
@ -9,17 +9,14 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
try {
|
||||
exceptionMessage(static function () {
|
||||
$validator = Validator::not(
|
||||
Validator::intVal()->positive()
|
||||
);
|
||||
$validator->check(2);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
2 must not be positive
|
||||
|
|
|
@ -8,34 +8,14 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Exceptions\ConsonantException;
|
||||
use Respect\Validation\Exceptions\IntTypeException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::allOf(v::intType(), v::positive()))->check(42);
|
||||
} catch (IntTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::allOf(v::stringType(), v::consonant())->check('Luke i\'m your father');
|
||||
} catch (ConsonantException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::allOf(v::stringType(), v::consonant())->assert(42);
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
exceptionMessage(static fn() => v::not(v::allOf(v::intType(), v::positive()))->check(42));
|
||||
exceptionMessage(static fn() => v::allOf(v::stringType(), v::consonant())->check('Luke i\'m your father'));
|
||||
exceptionFullMessage(static fn() => v::allOf(v::stringType(), v::consonant())->assert(42));
|
||||
exceptionFullMessage(static function () {
|
||||
v::not(v::allOf(v::stringType(), v::length(10)))->assert('Frank Zappa is fantastic');
|
||||
} catch (AllOfException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
});
|
||||
?>
|
||||
--EXPECT--
|
||||
42 must not be of type integer
|
||||
|
|
|
@ -7,57 +7,16 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AlnumException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::alnum()->check('abc%1');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alnum(' ')->check('abc%2');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum())->check('abcd3');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum('% '))->check('abc%4');
|
||||
} catch (AlnumException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alnum()->assert('abc^1');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum())->assert('abcd2');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alnum('* &%')->assert('abc^3');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alnum('^'))->assert('abc^4');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::alnum()->check('abc%1'));
|
||||
exceptionMessage(static fn() => v::alnum(' ')->check('abc%2'));
|
||||
exceptionMessage(static fn() => v::not(v::alnum())->check('abcd3'));
|
||||
exceptionMessage(static fn() => v::not(v::alnum('% '))->check('abc%4'));
|
||||
exceptionFullMessage(static fn() => v::alnum()->assert('abc^1'));
|
||||
exceptionFullMessage(static fn() => v::not(v::alnum())->assert('abcd2'));
|
||||
exceptionFullMessage(static fn() => v::alnum('* &%')->assert('abc^3'));
|
||||
exceptionFullMessage(static fn() => v::not(v::alnum('^'))->assert('abc^4'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"abc%1" must contain only letters (a-z) and digits (0-9)
|
||||
|
|
|
@ -7,57 +7,16 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AlphaException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::alpha()->check('aaa%a');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alpha(' ')->check('bbb%b');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha())->check('ccccc');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha('% '))->check('ddd%d');
|
||||
} catch (AlphaException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alpha()->assert('eee^e');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha())->assert('fffff');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alpha('* &%')->assert('ggg^g');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alpha('^'))->assert('hhh^h');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::alpha()->check('aaa%a'));
|
||||
exceptionMessage(static fn() => v::alpha(' ')->check('bbb%b'));
|
||||
exceptionMessage(static fn() => v::not(v::alpha())->check('ccccc'));
|
||||
exceptionMessage(static fn() => v::not(v::alpha('% '))->check('ddd%d'));
|
||||
exceptionFullMessage(static fn() => v::alpha()->assert('eee^e'));
|
||||
exceptionFullMessage(static fn() => v::not(v::alpha())->assert('fffff'));
|
||||
exceptionFullMessage(static fn() => v::alpha('* &%')->assert('ggg^g'));
|
||||
exceptionFullMessage(static fn() => v::not(v::alpha('^'))->assert('hhh^h'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"aaa%a" must contain only letters (a-z)
|
||||
|
|
|
@ -7,21 +7,10 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AlwaysInvalidException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::alwaysInvalid()->check('whatever');
|
||||
} catch (AlwaysInvalidException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::alwaysInvalid()->assert('');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::alwaysInvalid()->check('whatever'));
|
||||
exceptionFullMessage(static fn() => v::alwaysInvalid()->assert(''));
|
||||
?>
|
||||
--EXPECT--
|
||||
"whatever" is always invalid
|
||||
|
|
|
@ -7,22 +7,10 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AlwaysValidException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::alwaysValid())->check(true);
|
||||
} catch (AlwaysValidException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::alwaysValid())->assert(true);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::not(v::alwaysValid())->check(true));
|
||||
exceptionFullMessage(static fn() => v::not(v::alwaysValid())->assert(true));
|
||||
?>
|
||||
--EXPECT--
|
||||
`TRUE` is always invalid
|
||||
|
|
|
@ -8,33 +8,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ArrayTypeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::arrayType()->check('teste');
|
||||
} catch (ArrayTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayType())->check([]);
|
||||
} catch (ArrayTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::arrayType()->assert(new ArrayObject());
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayType())->assert([1, 2, 3]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::arrayType()->check('teste'));
|
||||
exceptionMessage(static fn() => v::not(v::arrayType())->check([]));
|
||||
exceptionFullMessage(static fn() => v::arrayType()->assert(new ArrayObject()));
|
||||
exceptionFullMessage(static fn() => v::not(v::arrayType())->assert([1, 2, 3]));
|
||||
?>
|
||||
--EXPECT--
|
||||
"teste" must be of type array
|
||||
|
|
|
@ -8,33 +8,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ArrayValException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::arrayVal()->check('Bla %123');
|
||||
} catch (ArrayValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayVal())->check([42]);
|
||||
} catch (ArrayValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::arrayVal()->assert(new stdClass());
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::arrayVal())->assert(new ArrayObject([2, 3]));
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::arrayVal()->check('Bla %123'));
|
||||
exceptionMessage(static fn() => v::not(v::arrayVal())->check([42]));
|
||||
exceptionFullMessage(static fn() => v::arrayVal()->assert(new stdClass()));
|
||||
exceptionFullMessage(static fn() => v::not(v::arrayVal())->assert(new ArrayObject([2, 3])));
|
||||
?>
|
||||
--EXPECT--
|
||||
"Bla %123" must be an array value
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\BaseException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::base(61)->check('Z01xSsg5675hic20dj');
|
||||
} catch (BaseException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::base(2)->assert('');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base(2))->check('011010001');
|
||||
} catch (BaseException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base(2))->assert('011010001');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::base(61)->check('Z01xSsg5675hic20dj'));
|
||||
exceptionFullMessage(static fn() => v::base(2)->assert(''));
|
||||
exceptionMessage(static fn() => v::not(v::base(2))->check('011010001'));
|
||||
exceptionFullMessage(static fn() => v::not(v::base(2))->assert('011010001'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"Z01xSsg5675hic20dj" must be a number in the base 61
|
||||
|
|
|
@ -9,33 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\Base64Exception;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::base64()->check('=c3VyZS4');
|
||||
} catch (Base64Exception $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base64())->check('c3VyZS4=');
|
||||
} catch (Base64Exception $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::base64()->assert('=c3VyZS4');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::base64())->assert('c3VyZS4=');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::base64()->check('=c3VyZS4'));
|
||||
exceptionMessage(static fn() => v::not(v::base64())->check('c3VyZS4='));
|
||||
exceptionFullMessage(static fn() => v::base64()->assert('=c3VyZS4'));
|
||||
exceptionFullMessage(static fn() => v::not(v::base64())->assert('c3VyZS4='));
|
||||
?>
|
||||
--EXPECT--
|
||||
"=c3VyZS4" must be Base64-encoded
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\BetweenException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::between(1, 2)->check(0);
|
||||
} catch (BetweenException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::between('yesterday', 'tomorrow'))->check('today');
|
||||
} catch (BetweenException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::between('a', 'c')->assert('d');
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::between(-INF, INF))->assert(0);
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::between(1, 2)->check(0));
|
||||
exceptionMessage(static fn() => v::not(v::between('yesterday', 'tomorrow'))->check('today'));
|
||||
exceptionFullMessage(static fn() => v::between('a', 'c')->assert('d'));
|
||||
exceptionFullMessage(static fn() => v::not(v::between(-INF, INF))->assert(0));
|
||||
?>
|
||||
--EXPECT--
|
||||
0 must be between 1 and 2
|
||||
|
|
|
@ -8,14 +8,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::between('a', 'b'))->assert('a');
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
exceptionFullMessage(static fn() => v::not(v::between('a', 'b'))->assert('a'));
|
||||
?>
|
||||
--EXPECT--
|
||||
- "a" must not be between "a" and "b"
|
||||
|
|
|
@ -8,14 +8,9 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\AllOfException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::not(v::intType()->between(1, 42))->assert(41);
|
||||
} catch (AllOfException $e) {
|
||||
echo $e->getFullMessage();
|
||||
}
|
||||
exceptionFullMessage(static fn() => v::not(v::intType()->between(1, 42))->assert(41));
|
||||
?>
|
||||
--EXPECT--
|
||||
- 41 must not be between 1 and 42
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\BoolTypeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::boolType()->check('teste');
|
||||
} catch (BoolTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolType())->check(true);
|
||||
} catch (BoolTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::boolType()->assert([]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolType())->assert(false);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::boolType()->check('teste'));
|
||||
exceptionMessage(static fn() => v::not(v::boolType())->check(true));
|
||||
exceptionFullMessage(static fn() => v::boolType()->assert([]));
|
||||
exceptionFullMessage(static fn() => v::not(v::boolType())->assert(false));
|
||||
?>
|
||||
--EXPECT--
|
||||
"teste" must be of type boolean
|
||||
|
|
|
@ -9,33 +9,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\BoolValException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::boolVal()->check('ok');
|
||||
} catch (BoolValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolVal())->check('yes');
|
||||
} catch (BoolValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::boolVal()->assert('yep');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::boolVal())->assert('on');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::boolVal()->check('ok'));
|
||||
exceptionMessage(static fn() => v::not(v::boolVal())->check('yes'));
|
||||
exceptionFullMessage(static fn() => v::boolVal()->assert('yep'));
|
||||
exceptionFullMessage(static fn() => v::not(v::boolVal())->assert('on'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"ok" must be a boolean value
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\BsnException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::bsn()->check('acb');
|
||||
} catch (BsnException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::bsn())->check('612890053');
|
||||
} catch (BsnException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::bsn()->assert('abc');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::bsn())->assert('612890053');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::bsn()->check('acb'));
|
||||
exceptionMessage(static fn() => v::not(v::bsn())->check('612890053'));
|
||||
exceptionFullMessage(static fn() => v::bsn()->assert('abc'));
|
||||
exceptionFullMessage(static fn() => v::not(v::bsn())->assert('612890053'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"acb" must be a BSN
|
||||
|
|
|
@ -7,46 +7,14 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CallException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::call('trim', v::noWhitespace())->check(' two words ');
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::call('trim', v::stringType()))->check(' something ');
|
||||
} catch (CallException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::call('trim', v::alwaysValid())->check([]);
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::call('strval', v::intType())->assert(1234);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::call('is_float', v::boolType()))->assert(1.2);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::call('array_walk', v::alwaysValid())->assert(INF);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::call('trim', v::noWhitespace())->check(' two words '));
|
||||
exceptionMessage(static fn() => v::not(v::call('trim', v::stringType()))->check(' something '));
|
||||
exceptionMessage(static fn() => v::call('trim', v::alwaysValid())->check([]));
|
||||
exceptionFullMessage(static fn() => v::call('strval', v::intType())->assert(1234));
|
||||
exceptionFullMessage(static fn() => v::not(v::call('is_float', v::boolType()))->assert(1.2));
|
||||
exceptionFullMessage(static fn() => v::call('array_walk', v::alwaysValid())->assert(INF));
|
||||
?>
|
||||
--EXPECT--
|
||||
"two words" must not contain whitespace
|
||||
|
|
|
@ -7,28 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CallableTypeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::callableType()->check([]);
|
||||
} catch (CallableTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::callableType())->check('trim');
|
||||
} catch (CallableTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::callableType()->assert(true);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::callableType()->check([]));
|
||||
exceptionMessage(static fn() => v::not(v::callableType())->check('trim'));
|
||||
exceptionFullMessage(static fn() => v::callableType()->assert(true));
|
||||
try {
|
||||
v::not(v::callableType())->assert(static function (): void {
|
||||
});
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CallbackException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::callback('is_string')->check([]);
|
||||
} catch (CallbackException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::callback('is_string'))->check('foo');
|
||||
} catch (CallbackException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::callback('is_string')->assert(true);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::callback('is_string'))->assert('foo');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::callback('is_string')->check([]));
|
||||
exceptionMessage(static fn() => v::not(v::callback('is_string'))->check('foo'));
|
||||
exceptionFullMessage(static fn() => v::callback('is_string')->assert(true));
|
||||
exceptionFullMessage(static fn() => v::not(v::callback('is_string'))->assert('foo'));
|
||||
?>
|
||||
--EXPECT--
|
||||
`{ }` must be valid
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CharsetException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::charset('ASCII')->check('açaí');
|
||||
} catch (CharsetException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::charset('UTF-8'))->check('açaí');
|
||||
} catch (CharsetException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::charset('ASCII')->assert('açaí');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::charset('UTF-8'))->assert('açaí');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::charset('ASCII')->check('açaí'));
|
||||
exceptionMessage(static fn() => v::not(v::charset('UTF-8'))->check('açaí'));
|
||||
exceptionFullMessage(static fn() => v::charset('ASCII')->assert('açaí'));
|
||||
exceptionFullMessage(static fn() => v::not(v::charset('UTF-8'))->assert('açaí'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"açaí" must be in the `{ "ASCII" }` charset
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CnhException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::cnh()->check('batman');
|
||||
} catch (CnhException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cnh())->check('02650306461');
|
||||
} catch (CnhException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::cnh()->assert('bruce wayne');
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cnh())->assert('02650306461');
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::cnh()->check('batman'));
|
||||
exceptionMessage(static fn() => v::not(v::cnh())->check('02650306461'));
|
||||
exceptionFullMessage(static fn() => v::cnh()->assert('bruce wayne'));
|
||||
exceptionFullMessage(static fn() => v::not(v::cnh())->assert('02650306461'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"batman" must be a valid CNH number
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CnpjException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::cnpj()->check('não cnpj');
|
||||
} catch (CnpjException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cnpj())->check('65.150.175/0001-20');
|
||||
} catch (CnpjException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::cnpj()->assert('test');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cnpj())->assert('65.150.175/0001-20');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::cnpj()->check('não cnpj'));
|
||||
exceptionMessage(static fn() => v::not(v::cnpj())->check('65.150.175/0001-20'));
|
||||
exceptionFullMessage(static fn() => v::cnpj()->assert('test'));
|
||||
exceptionFullMessage(static fn() => v::not(v::cnpj())->assert('65.150.175/0001-20'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"não cnpj" must be a valid CNPJ number
|
||||
|
|
|
@ -7,58 +7,16 @@ declare(strict_types=1);
|
|||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ControlException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::control()->check('16-50');
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::control('16')->check('16-50');
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::control())->check("\n");
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::control('16'))->check("16\n");
|
||||
} catch (ControlException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::control()->assert('Foo');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::control('Bar')->assert('Foo');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::control())->assert("\n");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::control('Bar'))->assert("Bar\n");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::control()->check('16-50'));
|
||||
exceptionMessage(static fn() => v::control('16')->check('16-50'));
|
||||
exceptionMessage(static fn() => v::not(v::control())->check("\n"));
|
||||
exceptionMessage(static fn() => v::not(v::control('16'))->check("16\n"));
|
||||
exceptionFullMessage(static fn() => v::control()->assert('Foo'));
|
||||
exceptionFullMessage(static fn() => v::control('Bar')->assert('Foo'));
|
||||
exceptionFullMessage(static fn() => v::not(v::control())->assert("\n"));
|
||||
exceptionFullMessage(static fn() => v::not(v::control('Bar'))->assert("Bar\n"));
|
||||
?>
|
||||
--EXPECT--
|
||||
"16-50" must contain only control characters
|
||||
|
|
|
@ -9,58 +9,16 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ConsonantException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::consonant()->check('aeiou');
|
||||
} catch (ConsonantException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::consonant('d')->check('daeiou');
|
||||
} catch (ConsonantException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::consonant())->check('bcd');
|
||||
} catch (ConsonantException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::consonant('a'))->check('abcd');
|
||||
} catch (ConsonantException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::consonant()->assert('aeiou');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::consonant('d')->assert('daeiou');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::consonant())->assert('bcd');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::consonant('a'))->assert('abcd');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::consonant()->check('aeiou'));
|
||||
exceptionMessage(static fn() => v::consonant('d')->check('daeiou'));
|
||||
exceptionMessage(static fn() => v::not(v::consonant())->check('bcd'));
|
||||
exceptionMessage(static fn() => v::not(v::consonant('a'))->check('abcd'));
|
||||
exceptionFullMessage(static fn() => v::consonant()->assert('aeiou'));
|
||||
exceptionFullMessage(static fn() => v::consonant('d')->assert('daeiou'));
|
||||
exceptionFullMessage(static fn() => v::not(v::consonant())->assert('bcd'));
|
||||
exceptionFullMessage(static fn() => v::not(v::consonant('a'))->assert('abcd'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"aeiou" must contain only consonants
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ContainsException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::contains('foo')->check('bar');
|
||||
} catch (ContainsException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::contains('foo'))->check('fool');
|
||||
} catch (ContainsException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::contains('foo')->assert(['bar']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::contains('foo', true))->assert(['bar', 'foo']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::contains('foo')->check('bar'));
|
||||
exceptionMessage(static fn() => v::not(v::contains('foo'))->check('fool'));
|
||||
exceptionFullMessage(static fn() => v::contains('foo')->assert(['bar']));
|
||||
exceptionFullMessage(static fn() => v::not(v::contains('foo', true))->assert(['bar', 'foo']));
|
||||
?>
|
||||
--EXPECT--
|
||||
"bar" must contain the value "foo"
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ContainsAnyException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::containsAny(['foo', 'bar'])->check('baz');
|
||||
} catch (ContainsAnyException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::containsAny(['foo', 'bar']))->check('fool');
|
||||
} catch (ContainsAnyException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::containsAny(['foo', 'bar'])->assert(['baz']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::containsAny(['foo', 'bar'], true))->assert(['bar', 'foo']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::containsAny(['foo', 'bar'])->check('baz'));
|
||||
exceptionMessage(static fn() => v::not(v::containsAny(['foo', 'bar']))->check('fool'));
|
||||
exceptionFullMessage(static fn() => v::containsAny(['foo', 'bar'])->assert(['baz']));
|
||||
exceptionFullMessage(static fn() => v::not(v::containsAny(['foo', 'bar'], true))->assert(['bar', 'foo']));
|
||||
?>
|
||||
--EXPECT--
|
||||
"baz" must contain at least one of the values `{ "foo", "bar" }`
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CountableException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::countable()->check(1.0);
|
||||
} catch (CountableException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::countable())->check([]);
|
||||
} catch (CountableException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::countable()->assert('Not countable!');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::countable())->assert(new ArrayObject());
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::countable()->check(1.0));
|
||||
exceptionMessage(static fn() => v::not(v::countable())->check([]));
|
||||
exceptionFullMessage(static fn() => v::countable()->assert('Not countable!'));
|
||||
exceptionFullMessage(static fn() => v::not(v::countable())->assert(new ArrayObject()));
|
||||
?>
|
||||
--EXPECT--
|
||||
1.0 must be countable
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CountryCodeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::countryCode()->check('1');
|
||||
} catch (CountryCodeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::countryCode())->check('BR');
|
||||
} catch (CountryCodeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::countryCode()->assert('1');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::countryCode())->assert('BR');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::countryCode()->check('1'));
|
||||
exceptionMessage(static fn() => v::not(v::countryCode())->check('BR'));
|
||||
exceptionFullMessage(static fn() => v::countryCode()->assert('1'));
|
||||
exceptionFullMessage(static fn() => v::not(v::countryCode())->assert('BR'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"1" must be a valid country
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CpfException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::cpf()->check('this thing');
|
||||
} catch (CpfException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cpf())->check('276.865.775-11');
|
||||
} catch (CpfException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::cpf()->assert('your mother');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::cpf())->assert('61836182848');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::cpf()->check('this thing'));
|
||||
exceptionMessage(static fn() => v::not(v::cpf())->check('276.865.775-11'));
|
||||
exceptionFullMessage(static fn() => v::cpf()->assert('your mother'));
|
||||
exceptionFullMessage(static fn() => v::not(v::cpf())->assert('61836182848'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"this thing" must be a valid CPF number
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CreditCardException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::creditCard('Discover')->check(3566002020360505);
|
||||
} catch (CreditCardException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::creditCard('Visa'))->check(4024007153361885);
|
||||
} catch (CreditCardException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::creditCard('MasterCard')->assert(3566002020360505);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::creditCard())->assert(5555444433331111);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::creditCard('Discover')->check(3566002020360505));
|
||||
exceptionMessage(static fn() => v::not(v::creditCard('Visa'))->check(4024007153361885));
|
||||
exceptionFullMessage(static fn() => v::creditCard('MasterCard')->assert(3566002020360505));
|
||||
exceptionFullMessage(static fn() => v::not(v::creditCard())->assert(5555444433331111));
|
||||
?>
|
||||
--EXPECT--
|
||||
3566002020360505 must be a valid "Discover" Credit Card number
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\CurrencyCodeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::currencyCode()->check('batman');
|
||||
} catch (CurrencyCodeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::currencyCode())->check('BRL');
|
||||
} catch (CurrencyCodeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::currencyCode()->assert('ppz');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::currencyCode())->assert('GBP');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::currencyCode()->check('batman'));
|
||||
exceptionMessage(static fn() => v::not(v::currencyCode())->check('BRL'));
|
||||
exceptionFullMessage(static fn() => v::currencyCode()->assert('ppz'));
|
||||
exceptionFullMessage(static fn() => v::not(v::currencyCode())->assert('GBP'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"batman" must be a valid currency
|
||||
|
|
|
@ -7,35 +7,14 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\DateException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
try {
|
||||
v::date()->check('2018-01-29T08:32:54+00:00');
|
||||
} catch (DateException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::date())->check('2018-01-29');
|
||||
} catch (DateException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::date()->assert('2018-01-29T08:32:54+00:00');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::date('d/m/Y'))->assert('29/01/2018');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::date()->check('2018-01-29T08:32:54+00:00'));
|
||||
exceptionMessage(static fn() => v::not(v::date())->check('2018-01-29'));
|
||||
exceptionFullMessage(static fn() => v::date()->assert('2018-01-29T08:32:54+00:00'));
|
||||
exceptionFullMessage(static fn() => v::not(v::date('d/m/Y'))->assert('29/01/2018'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"2018-01-29T08:32:54+00:00" must be a valid date in the format "2005-12-30"
|
||||
|
|
|
@ -7,60 +7,18 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\DateTimeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
try {
|
||||
v::dateTime()->check('FooBarBazz');
|
||||
} catch (DateTimeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::dateTime('c')->check('06-12-1995');
|
||||
} catch (DateTimeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::dateTime()->assert('QuxQuuxx');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::dateTime('r')->assert(2018013030);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::dateTime())->check('4 days ago');
|
||||
} catch (DateTimeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::dateTime('Y-m-d'))->check('1988-09-09');
|
||||
} catch (DateTimeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::dateTime())->assert('+3 weeks');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::dateTime('d/m/y'))->assert('23/07/99');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::dateTime()->check('FooBarBazz'));
|
||||
exceptionMessage(static fn() => v::dateTime('c')->check('06-12-1995'));
|
||||
exceptionFullMessage(static fn() => v::dateTime()->assert('QuxQuuxx'));
|
||||
exceptionFullMessage(static fn() => v::dateTime('r')->assert(2018013030));
|
||||
exceptionMessage(static fn() => v::not(v::dateTime())->check('4 days ago'));
|
||||
exceptionMessage(static fn() => v::not(v::dateTime('Y-m-d'))->check('1988-09-09'));
|
||||
exceptionFullMessage(static fn() => v::not(v::dateTime())->assert('+3 weeks'));
|
||||
exceptionFullMessage(static fn() => v::not(v::dateTime('d/m/y'))->assert('23/07/99'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"FooBarBazz" must be a valid date/time
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\DecimalException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::decimal(3)->check(0.1234);
|
||||
} catch (DecimalException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::decimal(2)->assert(0.123);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::decimal(5))->check(0.12345);
|
||||
} catch (DecimalException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::decimal(2))->assert(0.34);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::decimal(3)->check(0.1234));
|
||||
exceptionFullMessage(static fn() => v::decimal(2)->assert(0.123));
|
||||
exceptionMessage(static fn() => v::not(v::decimal(5))->check(0.12345));
|
||||
exceptionFullMessage(static fn() => v::not(v::decimal(2))->assert(0.34));
|
||||
?>
|
||||
--EXPECT--
|
||||
0.1234 must have 3 decimals
|
||||
|
|
|
@ -7,57 +7,16 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\DigitException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::digit()->check('abc');
|
||||
} catch (DigitException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::digit('-')->check('a-b');
|
||||
} catch (DigitException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::digit())->check('123');
|
||||
} catch (DigitException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::digit('-'))->check('1-3');
|
||||
} catch (DigitException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::digit()->assert('abc');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::digit('-')->assert('a-b');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::digit())->assert('123');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::digit('-'))->assert('1-3');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::digit()->check('abc'));
|
||||
exceptionMessage(static fn() => v::digit('-')->check('a-b'));
|
||||
exceptionMessage(static fn() => v::not(v::digit())->check('123'));
|
||||
exceptionMessage(static fn() => v::not(v::digit('-'))->check('1-3'));
|
||||
exceptionFullMessage(static fn() => v::digit()->assert('abc'));
|
||||
exceptionFullMessage(static fn() => v::digit('-')->assert('a-b'));
|
||||
exceptionFullMessage(static fn() => v::not(v::digit())->assert('123'));
|
||||
exceptionFullMessage(static fn() => v::not(v::digit('-'))->assert('1-3'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"abc" must contain only digits (0-9)
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\DirectoryException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::directory()->check('batman');
|
||||
} catch (DirectoryException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::directory())->check(dirname('/etc/'));
|
||||
} catch (DirectoryException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::directory()->assert('ppz');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::directory())->assert(dirname('/etc/'));
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::directory()->check('batman'));
|
||||
exceptionMessage(static fn() => v::not(v::directory())->check(dirname('/etc/')));
|
||||
exceptionFullMessage(static fn() => v::directory()->assert('ppz'));
|
||||
exceptionFullMessage(static fn() => v::not(v::directory())->assert(dirname('/etc/')));
|
||||
?>
|
||||
--EXPECT--
|
||||
"batman" must be a directory
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::domain()->check('batman');
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::domain())->check('r--w.com');
|
||||
} catch (ValidationException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::domain()->assert('p-éz-.kk');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::domain())->assert('github.com');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::domain()->check('batman'));
|
||||
exceptionMessage(static fn() => v::not(v::domain())->check('r--w.com'));
|
||||
exceptionFullMessage(static fn() => v::domain()->assert('p-éz-.kk'));
|
||||
exceptionFullMessage(static fn() => v::not(v::domain())->assert('github.com'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"batman" must contain the value "."
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\EachException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::each(v::dateTime())->check(null);
|
||||
} catch (EachException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::each(v::dateTime()))->check(['2018-10-10']);
|
||||
} catch (EachException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::each(v::dateTime())->assert(null);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::each(v::dateTime()))->assert(['2018-10-10']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::each(v::dateTime())->check(null));
|
||||
exceptionMessage(static fn() => v::not(v::each(v::dateTime()))->check(['2018-10-10']));
|
||||
exceptionFullMessage(static fn() => v::each(v::dateTime())->assert(null));
|
||||
exceptionFullMessage(static fn() => v::not(v::each(v::dateTime()))->assert(['2018-10-10']));
|
||||
?>
|
||||
--EXPECT--
|
||||
Each item in `NULL` must be valid
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\EmailException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::email()->check('batman');
|
||||
} catch (EmailException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::email())->check('bruce.wayne@gothancity.com');
|
||||
} catch (EmailException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::email()->assert('bruce wayne');
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::email())->assert('iambatman@gothancity.com');
|
||||
} catch (NestedValidationException $e) {
|
||||
echo $e->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::email()->check('batman'));
|
||||
exceptionMessage(static fn() => v::not(v::email())->check('bruce.wayne@gothancity.com'));
|
||||
exceptionFullMessage(static fn() => v::email()->assert('bruce wayne'));
|
||||
exceptionFullMessage(static fn() => v::not(v::email())->assert('iambatman@gothancity.com'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"batman" must be valid email
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\EndsWithException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::endsWith('foo')->check('bar');
|
||||
} catch (EndsWithException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::endsWith('foo'))->check(['bar', 'foo']);
|
||||
} catch (EndsWithException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::endsWith('foo')->assert('');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::endsWith('foo'))->assert(['bar', 'foo']);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::endsWith('foo')->check('bar'));
|
||||
exceptionMessage(static fn() => v::not(v::endsWith('foo'))->check(['bar', 'foo']));
|
||||
exceptionFullMessage(static fn() => v::endsWith('foo')->assert(''));
|
||||
exceptionFullMessage(static fn() => v::not(v::endsWith('foo'))->assert(['bar', 'foo']));
|
||||
?>
|
||||
--EXPECT--
|
||||
"bar" must end with "foo"
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\EqualsException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::equals(123)->check(321);
|
||||
} catch (EqualsException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::equals(321))->check(321);
|
||||
} catch (EqualsException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::equals(123)->assert(321);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::equals(321))->assert(321);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::equals(123)->check(321));
|
||||
exceptionMessage(static fn() => v::not(v::equals(321))->check(321));
|
||||
exceptionFullMessage(static fn() => v::equals(123)->assert(321));
|
||||
exceptionFullMessage(static fn() => v::not(v::equals(321))->assert(321));
|
||||
?>
|
||||
--EXPECT--
|
||||
321 must equal 123
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\EquivalentException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::equivalent(true)->check(false);
|
||||
} catch (EquivalentException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::equivalent('Something'))->check('someThing');
|
||||
} catch (EquivalentException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::equivalent(123)->assert('true');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::equivalent(true))->assert(1);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::equivalent(true)->check(false));
|
||||
exceptionMessage(static fn() => v::not(v::equivalent('Something'))->check('someThing'));
|
||||
exceptionFullMessage(static fn() => v::equivalent(123)->assert('true'));
|
||||
exceptionFullMessage(static fn() => v::not(v::equivalent(true))->assert(1));
|
||||
?>
|
||||
--EXPECT--
|
||||
`FALSE` must be equivalent to `TRUE`
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\EvenException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::even()->check(-1);
|
||||
} catch (EvenException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::even()->assert(5);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::even())->check(6);
|
||||
} catch (EvenException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::even())->assert(8);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::even()->check(-1));
|
||||
exceptionFullMessage(static fn() => v::even()->assert(5));
|
||||
exceptionMessage(static fn() => v::not(v::even())->check(6));
|
||||
exceptionFullMessage(static fn() => v::not(v::even())->assert(8));
|
||||
?>
|
||||
--EXPECT--
|
||||
-1 must be an even number
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ExecutableException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::executable()->check('bar');
|
||||
} catch (ExecutableException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::executable())->check('tests/fixtures/executable');
|
||||
} catch (ExecutableException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::executable()->assert('bar');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::executable())->assert('tests/fixtures/executable');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::executable()->check('bar'));
|
||||
exceptionMessage(static fn() => v::not(v::executable())->check('tests/fixtures/executable'));
|
||||
exceptionFullMessage(static fn() => v::executable()->assert('bar'));
|
||||
exceptionFullMessage(static fn() => v::not(v::executable())->assert('tests/fixtures/executable'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"bar" must be an executable file
|
||||
|
|
|
@ -7,36 +7,15 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ExistsException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::exists()->check('/path/of/a/non-existent/file');
|
||||
} catch (ExistsException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::exists())->check('tests/fixtures/valid-image.gif');
|
||||
} catch (ExistsException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::exists()->assert('/path/of/a/non-existent/file');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::exists())->assert('tests/fixtures/valid-image.png');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::exists()->check('/path/of/a/non-existent/file'));
|
||||
exceptionMessage(static fn() => v::not(v::exists())->check('tests/fixtures/valid-image.gif'));
|
||||
exceptionFullMessage(static fn() => v::exists()->assert('/path/of/a/non-existent/file'));
|
||||
exceptionFullMessage(static fn() => v::not(v::exists())->assert('tests/fixtures/valid-image.png'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"/path/of/a/non-existent/file" must exists
|
||||
"tests/fixtures/valid-image.gif" must not exists
|
||||
- "/path/of/a/non-existent/file" must exists
|
||||
- "tests/fixtures/valid-image.png" must not exists
|
||||
"/path/of/a/non-existent/file" must exist
|
||||
"tests/fixtures/valid-image.gif" must not exist
|
||||
- "/path/of/a/non-existent/file" must exist
|
||||
- "tests/fixtures/valid-image.png" must not exist
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\ExtensionException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::extension('png')->check('filename.txt');
|
||||
} catch (ExtensionException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::extension('gif'))->check('filename.gif');
|
||||
} catch (ExtensionException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::extension('mp3')->assert('filename.wav');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::extension('png'))->assert('tests/fixtures/invalid-image.png');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::extension('png')->check('filename.txt'));
|
||||
exceptionMessage(static fn() => v::not(v::extension('gif'))->check('filename.gif'));
|
||||
exceptionFullMessage(static fn() => v::extension('mp3')->assert('filename.wav'));
|
||||
exceptionFullMessage(static fn() => v::not(v::extension('png'))->assert('tests/fixtures/invalid-image.png'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"filename.txt" must have "png" extension
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FactorException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::factor(3)->check(2);
|
||||
} catch (FactorException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::factor(0))->check(300);
|
||||
} catch (FactorException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::factor(5)->assert(3);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::factor(6))->assert(1);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::factor(3)->check(2));
|
||||
exceptionMessage(static fn() => v::not(v::factor(0))->check(300));
|
||||
exceptionFullMessage(static fn() => v::factor(5)->assert(3));
|
||||
exceptionFullMessage(static fn() => v::not(v::factor(6))->assert(1));
|
||||
?>
|
||||
--EXPECT--
|
||||
2 must be a factor of 3
|
||||
|
|
|
@ -7,37 +7,15 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FalseValException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::falseVal()->check(true);
|
||||
} catch (FalseValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::falseVal())->check('false');
|
||||
} catch (FalseValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::falseVal()->assert(1);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::falseVal())->assert(0);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::falseVal()->check(true));
|
||||
exceptionMessage(static fn() => v::not(v::falseVal())->check('false'));
|
||||
exceptionFullMessage(static fn() => v::falseVal()->assert(1));
|
||||
exceptionFullMessage(static fn() => v::not(v::falseVal())->assert(0));
|
||||
?>
|
||||
--EXPECT--
|
||||
`TRUE` is not considered as "False"
|
||||
"false" is considered as "False"
|
||||
- 1 is not considered as "False"
|
||||
- 0 is considered as "False"
|
||||
`TRUE` must evaluate to `false`
|
||||
"false" must not evaluate to `false`
|
||||
- 1 must evaluate to `false`
|
||||
- 0 must not evaluate to `false`
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FibonacciException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::fibonacci()->check(4);
|
||||
} catch (FibonacciException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::fibonacci())->check(5);
|
||||
} catch (FibonacciException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::fibonacci()->assert(16);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::fibonacci())->assert(21);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::fibonacci()->check(4));
|
||||
exceptionMessage(static fn() => v::not(v::fibonacci())->check(5));
|
||||
exceptionFullMessage(static fn() => v::fibonacci()->assert(16));
|
||||
exceptionFullMessage(static fn() => v::not(v::fibonacci())->assert(21));
|
||||
?>
|
||||
--EXPECT--
|
||||
4 must be a valid Fibonacci number
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FileException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::file()->check('tests/fixtures/non-existent.sh');
|
||||
} catch (FileException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::file())->check('tests/fixtures/valid-image.png');
|
||||
} catch (FileException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::file()->assert('tests/fixtures/non-existent.sh');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::file())->assert('tests/fixtures/valid-image.png');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::file()->check('tests/fixtures/non-existent.sh'));
|
||||
exceptionMessage(static fn() => v::not(v::file())->check('tests/fixtures/valid-image.png'));
|
||||
exceptionFullMessage(static fn() => v::file()->assert('tests/fixtures/non-existent.sh'));
|
||||
exceptionFullMessage(static fn() => v::not(v::file())->assert('tests/fixtures/valid-image.png'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"tests/fixtures/non-existent.sh" must be a file
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FilterVarException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::filterVar(FILTER_VALIDATE_IP)->check(42);
|
||||
} catch (FilterVarException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::filterVar(FILTER_VALIDATE_BOOLEAN))->check('On');
|
||||
} catch (FilterVarException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::filterVar(FILTER_VALIDATE_EMAIL)->assert(1.5);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::filterVar(FILTER_VALIDATE_FLOAT))->assert(1.0);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::filterVar(FILTER_VALIDATE_IP)->check(42));
|
||||
exceptionMessage(static fn() => v::not(v::filterVar(FILTER_VALIDATE_BOOLEAN))->check('On'));
|
||||
exceptionFullMessage(static fn() => v::filterVar(FILTER_VALIDATE_EMAIL)->assert(1.5));
|
||||
exceptionFullMessage(static fn() => v::not(v::filterVar(FILTER_VALIDATE_FLOAT))->assert(1.0));
|
||||
?>
|
||||
--EXPECT--
|
||||
42 must be valid
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FiniteException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::finite()->check('');
|
||||
} catch (FiniteException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::finite())->check(10);
|
||||
} catch (FiniteException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::finite()->assert([12]);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::finite())->assert('123456');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::finite()->check(''));
|
||||
exceptionMessage(static fn() => v::not(v::finite())->check(10));
|
||||
exceptionFullMessage(static fn() => v::finite()->assert([12]));
|
||||
exceptionFullMessage(static fn() => v::not(v::finite())->assert('123456'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"" must be a finite number
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FloatTypeException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::floatType()->check('42.33');
|
||||
} catch (FloatTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::floatType())->check(INF);
|
||||
} catch (FloatTypeException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::floatType()->assert(true);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::floatType())->assert(2.0);
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::floatType()->check('42.33'));
|
||||
exceptionMessage(static fn() => v::not(v::floatType())->check(INF));
|
||||
exceptionFullMessage(static fn() => v::floatType()->assert(true));
|
||||
exceptionFullMessage(static fn() => v::not(v::floatType())->assert(2.0));
|
||||
?>
|
||||
--EXPECT--
|
||||
"42.33" must be of type float
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\FloatValException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::floatVal()->check('a');
|
||||
} catch (FloatValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::floatVal())->check(165.0);
|
||||
} catch (FloatValException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::floatVal()->assert('a');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::floatVal())->assert('165.7');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::floatVal()->check('a'));
|
||||
exceptionMessage(static fn() => v::not(v::floatVal())->check(165.0));
|
||||
exceptionFullMessage(static fn() => v::floatVal()->assert('a'));
|
||||
exceptionFullMessage(static fn() => v::not(v::floatVal())->assert('165.7'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"a" must be a float number
|
||||
|
|
|
@ -7,58 +7,16 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\GraphException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::graph()->check("foo\nbar");
|
||||
} catch (GraphException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::graph('foo')->check("foo\nbar");
|
||||
} catch (GraphException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::graph())->check('foobar');
|
||||
} catch (GraphException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::graph("\n"))->check("foo\nbar");
|
||||
} catch (GraphException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::graph()->assert("foo\nbar");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::graph('foo')->assert("foo\nbar");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::graph())->assert('foobar');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::graph("\n"))->assert("foo\nbar");
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
exceptionMessage(static fn() => v::graph()->check("foo\nbar"));
|
||||
exceptionMessage(static fn() => v::graph('foo')->check("foo\nbar"));
|
||||
exceptionMessage(static fn() => v::not(v::graph())->check('foobar'));
|
||||
exceptionMessage(static fn() => v::not(v::graph("\n"))->check("foo\nbar"));
|
||||
exceptionFullMessage(static fn() => v::graph()->assert("foo\nbar"));
|
||||
exceptionFullMessage(static fn() => v::graph('foo')->assert("foo\nbar"));
|
||||
exceptionFullMessage(static fn() => v::not(v::graph())->assert('foobar'));
|
||||
exceptionFullMessage(static fn() => v::not(v::graph("\n"))->assert("foo\nbar"));
|
||||
?>
|
||||
--EXPECT--
|
||||
"foo\nbar" must contain only graphical characters
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\GreaterThanException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::greaterThan(21)->check(12);
|
||||
} catch (GreaterThanException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::greaterThan('yesterday'))->check('today');
|
||||
} catch (GreaterThanException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::greaterThan('2018-09-09')->assert('1988-09-09');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::greaterThan('a'))->assert('ba');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::greaterThan(21)->check(12));
|
||||
exceptionMessage(static fn() => v::not(v::greaterThan('yesterday'))->check('today'));
|
||||
exceptionFullMessage(static fn() => v::greaterThan('2018-09-09')->assert('1988-09-09'));
|
||||
exceptionFullMessage(static fn() => v::not(v::greaterThan('a'))->assert('ba'));
|
||||
?>
|
||||
--EXPECT--
|
||||
12 must be greater than 21
|
||||
|
|
|
@ -7,33 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\HexRgbColorException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::hexRgbColor()->check('invalid');
|
||||
} catch (HexRgbColorException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::hexRgbColor())->check('#808080');
|
||||
} catch (HexRgbColorException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::hexRgbColor()->assert('invalid');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::hexRgbColor())->assert('#808080');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
exceptionMessage(static fn() => v::hexRgbColor()->check('invalid'));
|
||||
exceptionMessage(static fn() => v::not(v::hexRgbColor())->check('#808080'));
|
||||
exceptionFullMessage(static fn() => v::hexRgbColor()->assert('invalid'));
|
||||
exceptionFullMessage(static fn() => v::not(v::hexRgbColor())->assert('#808080'));
|
||||
?>
|
||||
--EXPECT--
|
||||
"invalid" must be a hex RGB color
|
||||
|
|
|
@ -7,34 +7,12 @@ declare(strict_types=1);
|
|||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Respect\Validation\Exceptions\IbanException;
|
||||
use Respect\Validation\Exceptions\NestedValidationException;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
try {
|
||||
v::iban()->check('SE35 5000 5880 7742');
|
||||
} catch (IbanException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::iban())->check('GB82 WEST 1234 5698 7654 32');
|
||||
} catch (IbanException $exception) {
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::iban()->assert('NOT AN IBAN');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
v::not(v::iban())->assert('HU93 1160 0006 0000 0000 1234 5676');
|
||||
} catch (NestedValidationException $exception) {
|
||||
echo $exception->getFullMessage() . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
exceptionMessage(static fn() => v::iban()->check('SE35 5000 5880 7742'));
|
||||
exceptionMessage(static fn() => v::not(v::iban())->check('GB82 WEST 1234 5698 7654 32'));
|
||||
exceptionFullMessage(static fn() => v::iban()->assert('NOT AN IBAN'));
|
||||
exceptionFullMessage(static fn() => v::not(v::iban())->assert('HU93 1160 0006 0000 0000 1234 5676'));?>
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('bcmath')) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue