sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

metadata #242

Open mfulton26 opened 2 years ago

mfulton26 commented 2 years ago

In addition to validating values I want to identify and redact, remove, or otherwise scrub personally identifiable information (PII) from objects when logging.

I can create my own object hierarchy to point to which values in my objects are PII but it feels repetitive to me. If I could instead define custom properties on Ow predicates and then introspect them when logging then I would be able to programmatically redact/remove/scrub properties accordingly.

I suspect there are other use cases for metadata too but this is my current one.

Maybe this is already somewhat possible by me using my own ES6 Symbols to add properties to predicates but I still need a way to introspect nested predicates, etc. I'll also need to figure out the TypeScript augmentations to play nice if I add my own properties via symbols.

Now that I've written this up I'm wondering if augmenting Ow myself is the way to go or if adding metadata to Ow predicates is still a feature worth exploring. I would appreciate some advise/perspective here. Thank you.