-
Notifications
You must be signed in to change notification settings - Fork 434
Closed
Labels
enhancementImprovement of existing features or bugfixImprovement of existing features or bugfix
Milestone
Description
As I can see, right now, only a simple String error for the message
field is supported.
I often need more complex errors with additional data, like this for example:
"errors": [
{
"message": "Validation failed",
"code": "validation_err",
"data": {
"username": {"code": "min_length", "message": "must be at least 5 characters long", "meta": {"min": 5, "max": 15}}
}
}
]
Do you see a way to implement this?
It would require changing the type of FieldResult
.
As an idea:
pub enum FieldError {
Simple(String),
Custom(String, json_value::Value),
}
type FieldResult<T> = Result<T, FieldError>;
The problem is the type of the extra data.
It would require either having FieldError be generic over a type that implements Serialize
(for serde) or tying it to a value type like serde_value or json_value::Value
.
Metadata
Metadata
Assignees
Labels
enhancementImprovement of existing features or bugfixImprovement of existing features or bugfix