Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #51
I leveraged validator.js to avoid writing too much code. Only two files are being required from that module, so the overall library size does not grow by too much for those who decide to use it on the client side. This also opens a door to tens of other custom validators if there is a need for them in future. Perhaps,
email()
andurl()
could now also be switched tovalidator.js
methods, but that's a topic for a different discussion.Unfortunately,
host()
did not catch two edge cases due to validatorjs/validator.js#704, so I commented out two lines in the tests. Not crucial for the PR to get merged, but worth noting for future.