-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"stricter" mode for input types? #3
Comments
Hi @Ocramius, from what I see the only possible issue would be For other scalars, I'd like your feedback on how a Valinor/src/Type/Types/BooleanType.php Lines 33 to 42 in 231c276
|
I would love a way to enforce strictness as well, especially when handling data received as input through an API. If i have specified an API endpoint to accept integers in a certain field, i would never expect a numeric string to work in such a field. |
Hi @dvaeversted that's an interesting point indeed. I will definitely think about a solution to this and keep you updated in this issue. |
Hi @dvaeversted, I finally managed to handle properly strict rules in the mapper. Any chance you take a look at #159, try it out on your side and give feedback? |
Released as 0.11.0. Enjoy! |
Nice! |
Currently, the default behavior of this library is to go through automatic casting, similar to what PHP does with implicit type coercion.
This is probably fine for most use-cases, so this issue is just a question: is it possible to force the library to require exact types as input?
The reason is mostly to avoid issues like floating point -> integer conversion (or the opposite) happening by accident: requiring API clients to provide cleaner data, rather than being "lax" about it.
In following example, all is good:
This is fine, but should there be a rounding error outside what PHP's floating point precision can handle, we would likely have an issue here.
The text was updated successfully, but these errors were encountered: