Skip to content
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

"Tag" boolean #85

Closed
cyrilchapon opened this issue Jun 26, 2018 · 1 comment
Closed

"Tag" boolean #85

cyrilchapon opened this issue Jun 26, 2018 · 1 comment

Comments

@cyrilchapon
Copy link

cyrilchapon commented Jun 26, 2018

What about a "booleanTag" type, which would match value against variable presence only ?

I mean having a simple (VAR != null) (loose null or undefined, roughly means "presence") check that would allow anything, (including 0 or "") as value to be truthy. Acting like a --param tag and simpler booleans.

This shouldn't be mixed with the true boolean type though, IMHO, as they are pretty different

command !!VAR
VAR="" node script.js true
VAR=0 node script.js true
VAR= node script.js true
node script.js false
const myenv = envalid({ 
  ...process.env,
  VAR: undefined
})

// myenv.VAR === false
const myenv = envalid({ 
  ...process.env,
  VAR: null
})

// myenv.VAR === false
@af
Copy link
Owner

af commented Jun 27, 2018

I personally don't think this is generally useful enough to be included with the library, although I think it should be possible to add to your own project as a custom validator. Thanks for the suggestion though!

@af af closed this as completed Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants