JoshuaKGoldberg / package.json-validator

Tools to validate package.json files
MIT License
107 stars 26 forks source link

🚀 Feature: Option to get the valid fields returned? #51

Open ErisDS opened 8 years ago

ErisDS commented 8 years ago

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?

JoshuaKGoldberg commented 5 months ago

I can't parse the JSON and pass pre-parsed JSON to package.json-validator as it expects a string

Indeed, that would be very nice! Tracked in #66 and accepting PRs.

get the valid JSON back

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 package.json files tend to not be huge- and adding new fields to the return of the parsing function makes its API a bit more complicated. Unless someone has a real strong use case for it, I'd rather avoid it.

Marking as status: in discussion to wait for someone to post that use case. Cheers!