v5.6.0 release notes
typeutil.Undefined improvements
With the introduction of the json omitzero tag in Go 1.24, the typeutil.Undefined type has been improved to support json marshaling and SQL scanning. If used in combination with the omitzero tag, the marshaling behavior will now be as expected for a non-present field. This means the type can now be used in models and response DTOs to selectively make fields visible or not in a response.
- Added the
SetandUnsetconvenience methods. - Improved documentation.
- Handle more cases in the
sql.Scannerimplementation to supportUndefined[T],*Undefined[T],Tor*Tvalues as input. typeutil.Undefinednow implementsjson.Marshaler. Only theValueis marshaled as opposed to previously where the entire struct was marshaled.
Validation
Bug fixes
- Fixed incorrect validation order when using composition for array elements.
- Repeated paths in a rule set are not allowed anymore and will result in a panic. This incorrect usage of
RuleSetcould lead to buggy behavior. - Fixed "illegal syntax" error when using ruleset composition for an array of objects.
New features
- Added the
Init()method to thevalidation.Validatorinterface.- This allows initializing validators in unit tests.
- This method can be overridden by developers in custom validators in case some additional custom values must be defined at initialization.
- This change doesn't require any change in existing code-bases as the new method is already implemented by
BaseValidator.
- Added
validation.WithMessage(), which overrides the language entry used to render the error message of a validator.- Original placeholders returned by the validator are still used to render the message.
- Type-dependent and "element" suffixes are not added when the message is overridden.
- Added
validation.OnlyIf()validator, which executes a validator only if a condition is met. It can be useful for conditional validation.
Miscellaneous
- Upgraded
github.com/golang-jwt/jwttogithub.com/golang-jwt/jwt/v5so theauth.JWTServicecan benefit from the latest features and security. This is not a breaking change but you will need to update your import path if you use theauth.JWTController.SigningMethodfield. - On successful authentication, the user is now injected in the request's
context.Context.- The user can be retrieved from the context using the new function
auth.UserFromContext().
- The user can be retrieved from the context using the new function