The Wayback Machine - https://web.archive.org/web/20201125091734/https://github.com/validatorjs/validator.js/issues/920
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

Feature Request: Need validation for XSD:AnyURI types #920

Open
raghunathchary opened this issue Oct 31, 2018 · 5 comments
Open

Feature Request: Need validation for XSD:AnyURI types #920

raghunathchary opened this issue Oct 31, 2018 · 5 comments

Comments

@raghunathchary
Copy link

@raghunathchary raghunathchary commented Oct 31, 2018

Hi!

I'm checking to see if I can use validator.js for validating the XSD AnyURI string documented here but I see there is no OOB method to do so..

Please consider to add this in future releases.
Thanks,

@DCtheTall
Copy link
Contributor

@DCtheTall DCtheTall commented Oct 6, 2019

I'd be interested in taking this. I've contributed before though so if you want someone new to take this totally understand.

@profnandaa
Copy link
Collaborator

@profnandaa profnandaa commented Oct 8, 2019

@DCtheTall -- no worries, please take it up.

@DCtheTall
Copy link
Contributor

@DCtheTall DCtheTall commented Oct 11, 2019

Been looking into this some, and while I have an idea of where to start, it turns out the definition of these is quite broad. This might be more complex than I anticipated.

This link also provides some useful documentation including what ranges of Unicode values are allowed for this type.

So far here are some "base case" rules I have learned:

  • xsd:anyURI strings ignore any leading or trailing whitespace, so the first thing we should do after asserting the input is a string is call trim().

  • An empty string is valid, so we check for that. As far as I can tell from the docs, there is no upper bound on the length.

  • We can then check that each character is in the ranges specified in the link above.

  • Any URL is valid, so we can use isURL to check for those.

Still doing some research, but I would definitely appreciate any pointers. Like I said, it turns out the definition for these strings is actually pretty broad.

One alternative we could consider is adding a function which validates International Resource Identifiers (IRI), which are also mentioned in the link I provided.

@DCtheTall
Copy link
Contributor

@DCtheTall DCtheTall commented Oct 28, 2019

@profnandaa any ideas on how to go forward with this? I admit I am a bit stuck given how broad the definition of this string type is.

@profnandaa
Copy link
Collaborator

@profnandaa profnandaa commented Nov 10, 2020

@DCtheTall -- I'm very sorry I missed on this reply... Perhaps we just add an enhancement/option on isURL to support this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.