-
Notifications
You must be signed in to change notification settings - Fork 64
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
conditionally required field, requiredWhen validator spec #223
Conversation
What a timing. I need this :D Thank you @NewBieCoderXD. |
Thanks for the PR, this looks promising! I'll need to refresh myself with the history on this feature request and do a review, will try and get to that in the next couple days |
example/server.js
Outdated
const server = (env.USE_TLS)? http.createServer(serverBody): https.createServer({ | ||
key: fs.readFileSync(env.TLS_KEY_PATH), | ||
cert: fs.readFileSync(env.TLS_CERT_PATH) | ||
},serverBody); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you roll back the changes to this example file? IMO they make this very simple file harder to follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing!
Sorry for the slow response, this one got away from me! I have a couple things to address but will push them in a separate commit. Thanks for the contribution! |
Hi @af, Now that this PR has been merged. Will it go out in an 8.1 release? I'm really keen to use this new feature. Thanks to both yourself and of course @NewBieCoderXD for getting this in. |
heavily inspired by @neezer, #78, and #81
How it works:
instead of validate requirement based on raw env, we clean the env, then check if it is required.
requiredWhen is a boolean function that takes cleaned env then returns if the field is required.
I think this would get rid of most of the problems by using cleaned env instead of raw.
let me know what you think :)
(this is actually my first few PR outside of university, so I'm sorry if I've done anything wrong)