innoave / valid

composable validation functions for custom types
Other
14 stars 0 forks source link

How can I change the default message? #7

Closed benjamingb closed 5 months ago

benjamingb commented 3 years ago

How can I customize the default message? I want it to come out in another language

haraldmaida commented 3 years ago

The payloads of the enum ContraintViolation have a field code. The idea of this field is, that it contains a predefined key that can be mapped to a user friendly message in any language. The codes that are used by the validations provided by this crate can be found in the module validation. The defined codes are the constants with names like INVALID_..... The translation of the messages and how to choose a users language is no scope of this crate. It should be possible to combine this crate with any lib that provides localization support.