Skip to content

Commit b455d66

Browse files
committed
refactor types validation mevdschee#648
1 parent e6c6225 commit b455d66

File tree

11 files changed

+453
-425
lines changed

11 files changed

+453
-425
lines changed

README.md

+42-45
Original file line numberDiff line numberDiff line change
@@ -923,39 +923,36 @@ You can parse this output to make form fields show up with a red border and thei
923923
#### Validation types
924924

925925
The default types validations return the following error messages:
926-
| error message | applies to types |
927-
| ---- | ---- |
928-
| cannot be null | any non-nullable column |
929-
| must be numeric | integer bigint |
930-
| exceeds range | integer bigint |
931-
| too long | varchar varbinary |
932-
| not a float | decimal float double |
933-
| not a valid boolean | boolean |
934-
| invalid date format use yyyy-mm-dd | date timestamp |
935-
| not a valid date | date timestamp |
936-
| invalid time format use hh:mm:ss | time timestamp |
937-
| non-numeric time value | time timestamp |
938-
| not a valid time | time timestamp |
939-
| invalid timestamp format use yyyy-mm-dd hh:mm:ss | timestamp |
940-
941-
If you want the types validation to apply to all the types, you must activate the `validation` middleware.
926+
927+
| error message | reason | applies to types |
928+
| ------------------- | --------------------------- | ------------------------------------------- |
929+
| cannot be null | unexpected null value | (any non-nullable column) |
930+
| illegal whitespace | leading/trailing whitespace | integer bigint decimal float double boolean |
931+
| invalid integer | illegal characters | integer bigint |
932+
| string too long | too many characters | varchar varbinary |
933+
| invalid decimal | illegal characters | decimal |
934+
| decimal too large | too many digits before dot | decimal |
935+
| decimal too precise | too many digits after dot | decimal |
936+
| invalid float | illegal characters | float double |
937+
| invalid boolean | use 1, 0, true or false | boolean |
938+
| invalid date | use yyyy-mm-dd | date |
939+
| invalid time | use hh:mm:ss | time |
940+
| invalid timestamp | use yyyy-mm-dd hh:mm:ss | timestamp |
941+
942+
If you want the types validation to apply to all the types, you must activate the "`validation`" middleware.
942943
By default, all types are enabled. Which is equivalent to the two configuration possibilities:
943944

944945
'validation.types' => 'all',
945946

946947
or
947-
948-
'validation.types'=> 'integer,bigint,varchar,decimal,float,double,boolean,date,time,timestamp,clob,blob,varbinary,geometry',
949948

950-
Types with no declared error message can be checked whether null when the column is non-nullable.
949+
'validation.types'=> 'integer,bigint,varchar,decimal,float,double,boolean,date,time,timestamp,clob,blob,varbinary,geometry',
951950

952-
In case you want to use a validation handler but don't want any types validation, use either:
951+
In case you want to use a validation handler but don't want any types validation, use:
953952

954953
'validation.types' => '',
955-
956-
or
957-
958-
'validation.types'=> 'none',
954+
955+
NB: Types that are enabled will be checked for null values when the column is non-nullable.
959956

960957
### Multi-tenancy support
961958

@@ -1211,10 +1208,10 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
12111208
[3/4] Starting SQLServer 2017 ... skipped
12121209
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12131210
------------------------------------------------
1214-
mysql: 104 tests ran in 2869 ms, 1 skipped, 0 failed
1215-
pgsql: 104 tests ran in 850 ms, 1 skipped, 0 failed
1211+
mysql: 105 tests ran in 2986 ms, 1 skipped, 0 failed
1212+
pgsql: 105 tests ran in 976 ms, 1 skipped, 0 failed
12161213
sqlsrv: skipped, driver not loaded
1217-
sqlite: 104 tests ran in 883 ms, 12 skipped, 0 failed
1214+
sqlite: 105 tests ran in 933 ms, 12 skipped, 0 failed
12181215
================================================
12191216
Debian 10 (PHP 7.3)
12201217
================================================
@@ -1223,10 +1220,10 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
12231220
[3/4] Starting SQLServer 2017 ... skipped
12241221
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12251222
------------------------------------------------
1226-
mysql: 104 tests ran in 3056 ms, 1 skipped, 0 failed
1227-
pgsql: 104 tests ran in 869 ms, 1 skipped, 0 failed
1223+
mysql: 105 tests ran in 3214 ms, 1 skipped, 0 failed
1224+
pgsql: 105 tests ran in 904 ms, 1 skipped, 0 failed
12281225
sqlsrv: skipped, driver not loaded
1229-
sqlite: 104 tests ran in 891 ms, 12 skipped, 0 failed
1226+
sqlite: 105 tests ran in 1145 ms, 12 skipped, 0 failed
12301227
================================================
12311228
Debian 9 (PHP 7.0)
12321229
================================================
@@ -1235,10 +1232,10 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
12351232
[3/4] Starting SQLServer 2017 ... skipped
12361233
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12371234
------------------------------------------------
1238-
mysql: 104 tests ran in 2800 ms, 1 skipped, 0 failed
1239-
pgsql: 104 tests ran in 867 ms, 1 skipped, 0 failed
1235+
mysql: 105 tests ran in 2940 ms, 1 skipped, 0 failed
1236+
pgsql: 105 tests ran in 992 ms, 1 skipped, 0 failed
12401237
sqlsrv: skipped, driver not loaded
1241-
sqlite: 104 tests ran in 1051 ms, 12 skipped, 0 failed
1238+
sqlite: 105 tests ran in 1063 ms, 12 skipped, 0 failed
12421239
================================================
12431240
Ubuntu 16.04 (PHP 7.0)
12441241
================================================
@@ -1247,9 +1244,9 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
12471244
[3/4] Starting SQLServer 2017 ... done
12481245
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12491246
------------------------------------------------
1250-
mysql: 104 tests ran in 2789 ms, 1 skipped, 0 failed
1251-
pgsql: 104 tests ran in 872 ms, 1 skipped, 0 failed
1252-
sqlsrv: 104 tests ran in 7728 ms, 1 skipped, 0 failed
1247+
mysql: 105 tests ran in 3015 ms, 1 skipped, 0 failed
1248+
pgsql: 105 tests ran in 992 ms, 1 skipped, 0 failed
1249+
sqlsrv: 105 tests ran in 10515 ms, 1 skipped, 0 failed
12531250
sqlite: skipped, driver not loaded
12541251
================================================
12551252
Ubuntu 18.04 (PHP 7.2)
@@ -1259,10 +1256,10 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
12591256
[3/4] Starting SQLServer 2017 ... skipped
12601257
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12611258
------------------------------------------------
1262-
mysql: 104 tests ran in 3282 ms, 1 skipped, 0 failed
1263-
pgsql: 104 tests ran in 856 ms, 1 skipped, 0 failed
1259+
mysql: 105 tests ran in 3390 ms, 1 skipped, 0 failed
1260+
pgsql: 105 tests ran in 936 ms, 1 skipped, 0 failed
12641261
sqlsrv: skipped, driver not loaded
1265-
sqlite: 104 tests ran in 972 ms, 12 skipped, 0 failed
1262+
sqlite: 105 tests ran in 1063 ms, 12 skipped, 0 failed
12661263
================================================
12671264
Ubuntu 20.04 (PHP 7.3)
12681265
================================================
@@ -1271,10 +1268,10 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
12711268
[3/4] Starting SQLServer 2017 ... skipped
12721269
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12731270
------------------------------------------------
1274-
mysql: 104 tests ran in 5996 ms, 1 skipped, 0 failed
1275-
pgsql: 104 tests ran in 942 ms, 1 skipped, 0 failed
1271+
mysql: 105 tests ran in 6434 ms, 1 skipped, 0 failed
1272+
pgsql: 105 tests ran in 979 ms, 1 skipped, 0 failed
12761273
sqlsrv: skipped, driver not loaded
1277-
sqlite: 104 tests ran in 961 ms, 12 skipped, 0 failed
1274+
sqlite: 105 tests ran in 1373 ms, 12 skipped, 0 failed
12781275

12791276
The above test run (including starting up the databases) takes less than 5 minutes on my slow laptop.
12801277

@@ -1294,10 +1291,10 @@ The above test run (including starting up the databases) takes less than 5 minut
12941291
[3/4] Starting SQLServer 2017 ... skipped
12951292
[4/4] Cloning PHP-CRUD-API v2 ... skipped
12961293
------------------------------------------------
1297-
mysql: 104 tests ran in 3282 ms, 1 skipped, 0 failed
1298-
pgsql: 104 tests ran in 856 ms, 1 skipped, 0 failed
1294+
mysql: 105 tests ran in 3390 ms, 1 skipped, 0 failed
1295+
pgsql: 105 tests ran in 936 ms, 1 skipped, 0 failed
12991296
sqlsrv: skipped, driver not loaded
1300-
sqlite: 104 tests ran in 972 ms, 12 skipped, 0 failed
1297+
sqlite: 105 tests ran in 1063 ms, 12 skipped, 0 failed
13011298
root@b7ab9472e08f:/php-crud-api#
13021299

13031300
As you can see the "run.sh" script gives you access to a prompt in a chosen the docker environment.

0 commit comments

Comments
 (0)