-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Is your feature request related to a problem? Please describe.
It would be great to not have to write a message for each schema, especially when the error message is not used in the client side.
Describe the solution you'd like
Make every schema's message property optional, enabling the library to provide its own message (in english).
import * as Kryptonian from "kryptonian";
// This
Kryptonian.Kalel.string({
rules: []
});
// Instead of this
Kryptonian.Kalel.string({
message: "",
rules: []
});import * as Kryptonian from "kryptonian";
// This
Kryptonian.Kalel.string({
rules: [
Kryptonian.Kalel.String.email()
]
});
// Instead of this
Kryptonian.Kalel.string({
rules: [
Kryptonian.Kalel.String.email({
message: "This should be a valid email"
})
]
});Describe alternatives you've considered
None.
Additional context
This does not prevent the library from being type safe! This only make the property optional, with a default message that can still be relevant for most purposes.
Also, the library will still check for the schema to be in accordance with the data, and if this is not the case, a BadRequestError will still be raised (and would still require to be accounted for).