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

Enhancement - added URL validator #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joefitter
Copy link
Contributor

We have a requirement for a URL validator in ROTM. This cannot be achieved by using a regex validator as it is an optional field.

  • added url validator
  • added tests

@joefitter
Copy link
Contributor Author

@easternbloc @JoeChapman @gavboulton @HughePaul mind having a look?

@gavboulton
Copy link
Contributor

@joefitter I've added more test cases but 'something.com.' is failing.

@gavboulton gavboulton force-pushed the enhancement/add-url-validator-master branch from 6d98f32 to a0011b4 Compare March 9, 2017 16:48
@@ -20,6 +20,10 @@ module.exports = Validators = {
return value !== undefined && value !== '';
},

url: function url(value) {
return value === '' || Validators.regex(value, /[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+~#?&//=]*$/);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this enforce an optional protocol part? at the moment any chars are allowed at the start as there is no ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could...

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

Successfully merging this pull request may close these issues.

3 participants