-
Notifications
You must be signed in to change notification settings - Fork 29
🚀 Feature: Option to get the valid fields returned? #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Indeed, that would be very nice! Tracked in #66 and accepting PRs.
Hmm. I can see a use case for consumers who pass in a string, even after #66 is in. But parsing JSON isn't too expensive -especially given that Marking as |
Now that #66 has landed, it's possible to pass the parsed object into |
I like that. Going even further, should we augment the output result to link field names to errors, when possible? What if you wanted to know, for example, which error(s) link to which invalid field name(s)? |
That's kind of where my head went at first too, but I was trying to think of an approach that wouldn't be breaking. I guess rather than an array of invalid field names, it could be a Record of invalid field names to array of indices in the errors array that correspond to those fields? That way the existing errors array remains untouched, and the change is additive. |
OR(!) if we're ok with breaking changes, then we could change the errors array to be an array of error objects with message and field. That would allow you to filter by field or map to array of invalid fields. I kind of like this one as a means to support: #230 (comment). We could still do it with the keys of a Record object, but it feels a bit less ergonomic imho. |
👍 yeah! Despite all the tomfoolery with the automation in #230 -> #243 (whoops), we're still 0.x.
Hmm, what about about it feels non-ergonomic to you? I like the idea of keying by field. That way folks can quickly do checks like The only downside I can think of would be, what if we have validations that act cross-field? Then a single 1-to-many relationship wouldn't make sense. We'd have to have many-to-many. IMO it should be either:
Keeping to one-field-per-report would keep things simpler IMO. So it'd be nice if we can keep to it without losing any potential reports. Can you think of a case where we'd want a multi-field report? |
In a future state, wouldn't they just use I think the purpose of the
For sure, I don't think this proposal changes that. It's more about making it highly consumable for whatever form the end user might want to use the information. |
Hi there, I'm using this module as part of a bigger validator for Ghost themes.
After I've checked that the package.json is valid, I want to use some of the fields to inform my report (name, version, description, etc) and eventually I'd like to add a few extra validations of my own which are Ghost-specific.
At the moment, I end up having to do some work twice. I can't parse the JSON and pass pre-parsed JSON to package.json-validator as it expects a string, but I also don't believe it's currently possible to get the parsed JSON back from PJV to do further work on.
I'm happy to submit a PR, but thought I'd check first, would the option to get the valid JSON back be something that would be accepted? Any thoughts or recommendations on naming or approach?
The text was updated successfully, but these errors were encountered: