jhthorsen / json-validator

:cop: Validate data against a JSON schema
https://metacpan.org/release/JSON-Validator
56 stars 58 forks source link

Remove coerce() and just coerce everything #248

Closed jhthorsen closed 3 years ago

jhthorsen commented 3 years ago

I'm considering removing the coerce() method and just enable coercion by default. I'm unsure which benefit it adds, especially considering that J::V is often used for data over HTTP which in most cases needs coercion.

Another thing is data from an unstructured database will also often just be strings, which needs to be coerced into integers, numbers, ...

Any input?

jhthorsen commented 3 years ago

Does not seem like this changes anything.

https://github.com/jhthorsen/json-validator/commit/5e602308a3e01dd3c2ae1fb99bd07f354a8b3e61#diff-1404a1d87322e5fd93bc0b9aa78f1fdb5e555116ca145f27ce499a6ca9c9c0eaR86-R90

I also ran the same benchmark, where code that check {coerce} was completely removed, and it did not change anything.