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
Right now the an error message looks something like this:
[{field: 'data.y',message: 'is required'},{field: 'data.x',message: 'is the wrong type'}]
This makes it easy to work with until one of the field names contains a period. Using json-pointer would solve this. It's extremely fast to build and parse, is a well known standard, and is already part of json-schema.
// the object{'domains': {'www.google.com': {'company_name': 22}}}// the error[{field: 'domains.www.google.com.company_name',message: 'is the wrong type'}]// using json-pointer[{field: '/domains/www.google.com/company_name',message: 'is the wrong type'}]
The text was updated successfully, but these errors were encountered:
A forward slash is also a valid key in JSON unfortunately - in fact any valid string can be used as a key. So for this to work simply switching the delimiter will not do the trick :(
I haven't really thought through the implications of fixing this issue - so I'm purely speaking from a technical perspective here - but I think apart from moving to a nested structure in the error messages as well, we'd have to resort to escaping to non-delimiters... at least that's the only thing I can think of right now.
Ah yes, the json-pointer spec already handles escaping by using ~1 to replace a slash, and ~0 to replace a tilda. This makes for really performant single-pass encoding/decoding.
Honestly, I suggest using this mostly because it is a well accepted standard; IMHO the best way to specify a path is an array of segments, which is more useful and used language constructs instead of convention to ensure fidelity.
I would love to have this implemented, since currently a root-object called data is appended to the fields. This means that your first error in the second example actually is this:
[{field: 'data.domains.www.google.com.company_name',message: 'is the wrong type'}]
Notice the data. part. This confused me big time as documented in #109.
I think that it would be immensely useful for it to print / for the root instead of data..
@mafintosh If you give the go-ahead, I would be happy to implement this for you :)
Right now the an error message looks something like this:
This makes it easy to work with until one of the field names contains a period. Using json-pointer would solve this. It's extremely fast to build and parse, is a well known standard, and is already part of json-schema.
The text was updated successfully, but these errors were encountered: