You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While for most apps loose decoding is acceptable (and may be even preferable for speed), some require strict checking of form params (for ex. OAuth2 spec require this), and some other may like to enable it to make it easier to catch some bugs (like sending param with typo in name which now gets ignored by default and such bug may not be noticed for some time).
Returning new errors triggered by strict mode will require minor API changes:
Decode() should return new error type(s) in addition to InvalidDecoderError and DecodeErrors
probably Mode should be changed to use 1<<iota>>1 and have few more values added, which can be ORed with existing values to (partially) enable strict mode
Here is complete (I hope) list of changes required for strict mode:
multiple values for non-slice/array field Update: (except []byte)
also pointer to slice/array (if such types are supported)
Update: including multiple values for same array[index] or map[key], in case this array/map doesn't have values of slice/array type
error on decoding no values to non-pointer/slice/array field tagged ",required"
I'm going to implement (at least, partially) this for my service, but implementing in a separate package will not be effective (because I'll have to duplicate existing functionality of form to reflect data structure, check field types and tags) and probably will be incomplete (not sure I can detect registered custom handlers for whole struct).
If you like the idea and open to discussing related PR then I'll try to implement this inside form and send a PR.
While for most apps loose decoding is acceptable (and may be even preferable for speed), some require strict checking of form params (for ex. OAuth2 spec require this), and some other may like to enable it to make it easier to catch some bugs (like sending param with typo in name which now gets ignored by default and such bug may not be noticed for some time).
Returning new errors triggered by strict mode will require minor API changes:
1<<iota>>1and have few more values added, which can be ORed with existing values to (partially) enable strict modeHere is complete (I hope) list of changes required for strict mode:
[]byte)array[index]ormap[key], in case this array/map doesn't have values of slice/array typeI'm going to implement (at least, partially) this for my service, but implementing in a separate package will not be effective (because I'll have to duplicate existing functionality of form to reflect data structure, check field types and tags) and probably will be incomplete (not sure I can detect registered custom handlers for whole struct).
If you like the idea and open to discussing related PR then I'll try to implement this inside form and send a PR.