Closed geoffturk closed 1 week ago
All error messages should clearly identify the field that caused the error and the schema(s) which contain that field that failed validation. For example:
{
"errors": [
{
"status": 400,
"source": {
"pointer": "/primary_url"
},
"title": "Pattern Mismatch",
"detail": "The submitted data does not match the required pattern: '^https?://.*' - Schema: organizations_schema-v1.0.0"
}
]
}
Here's an example of a profile (https://ic3.dev/murmurations/field-length-limits.json) that is failing validation, and the errors messages are not containing all of fields to easily locate the offending field:
{
"errors": [
{
"status": 400,
"title": "Invalid Length, max length is 100",
"detail": "String length exceeded"
},
{
"status": 400,
"title": "Invalid Length, max length is 3",
"detail": "String length exceeded"
},
{
"status": 400,
"title": "Invalid Length, max length is 2000",
"detail": "String length exceeded"
},
{
"status": 400,
"source": {
"pointer": "/tags"
},
"title": "Too Many Tags",
"detail": "Maximum of 100 tags allowed"
},
{
"status": 400,
"source": {
"pointer": "/tags"
},
"title": "Tag Too Long",
"detail": "Each tag should be under 100 characters"
},
{
"status": 400,
"title": "Invalid Length, max length is 200",
"detail": "String length exceeded"
},
{
"status": 400,
"title": "Invalid Length, max length is 100",
"detail": "String length exceeded"
}
]
}
https://github.com/xeipuuv/gojsonschema/blob/master/errors.go https://github.com/xeipuuv/gojsonschema/blob/master/locales.go
https://github.com/MurmurationsNetwork/MurmurationsServices/blob/main/pkg/validatenode/validatenode.go https://github.com/MurmurationsNetwork/MurmurationsServices/blob/main/pkg/profile/profilevalidator/profilevalidator.go