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
I have looked at the examples provided that may showcase my question here?
Package version eg. v9, v10:
v10
Enhancement:
Topic: Add support for Type-specific Validation based on Interface.
I'd like to propose to extend the required validation logic (under a new name, e.g. must) from a simple "Not Zero" check to contain an alternative path which would call an interface – if present – on the type and validate based on the implemented logic.
The interface could look like
typeValidatorinterface { Validate() error }
Benefit with this interface: It is compatible with other validation libs as well.
Adding this validation, will allow to define custom type-specific validations and ensure their invocation based on the given tag (e.g. must).
If the validator interface is not defined on a type, the validation logic will fallback to the required validation logic.
Alternatively: The validation could also first perform the required validation and subsequently perform the interface based validation logic.
Package version eg. v9, v10:
v10
Enhancement:
Topic: Add support for Type-specific Validation based on Interface.
I'd like to propose to extend the
required
validation logic (under a new name, e.g.must
) from a simple "Not Zero" check to contain an alternative path which would call an interface – if present – on the type and validate based on the implemented logic.The interface could look like
Benefit with this interface: It is compatible with other validation libs as well.
Adding this validation, will allow to define custom type-specific validations and ensure their invocation based on the given tag (e.g.
must
).If the validator interface is not defined on a type, the validation logic will fallback to the
required
validation logic.Alternatively: The validation could also first perform the
required
validation and subsequently perform the interface based validation logic.Feedback highly appreciated.
Similar Request: Issue 854
Code sample, to showcase or reproduce:
The text was updated successfully, but these errors were encountered: