WebbyLab / php-validator-livr

Lightweight PHP validator supporting Language Independent Validation Rules Specification (LIVR)
45 stars 16 forks source link

Update test suites, implement v2.0 features #23

Closed k33nice closed 7 years ago

k33nice commented 7 years ago

@koorchik After updating test suites from V2.0, and implementing new features some problems have emerged. PHP language implements Array as decorated HashMap, and json_decode function, with passed 'true' as second argument, parse JSON string into PHP Array. Thus it's impossible to figure out javascript empty object or empty array in JSON string by decoding into PHP Array. Anyway it's posible, if parse JSON string with passing 'false' as second argument (in that case json_decode convert javascript objects into PHP stdClasses), but it would be weird cos native PHP url parser produce associative Array instead of stdClass. So PHP programmers are used to parse JSON in PHP Array.

koorchik commented 7 years ago

You can just make simple update to your test_suite files. I guess, replacing empty {} with empty [] is enough.

k33nice commented 7 years ago

@koorchik Not exactly, for example for rule anyObject we have positive test with {}, and negative with [], so needs to remove one of (https://github.com/k33nice/php-validator-livr/commit/f93a1b76b1df77141cf9e223c3e17b9d01bc2fe2). Its's posible to pass by modifying test_suites, but that's broke cross-language test_suites compability, and complicate updating.