srkirkland / DataAnnotationsExtensions

Validation extensions for DataAnnotations, including optional MVC client validation implementations
https://dataannotationsextensions.apphb.com/
BSD 3-Clause "New" or "Revised" License
308 stars 86 forks source link

Allow protocol to be explicitly excluded from Url attribute #35

Closed spib closed 12 years ago

spib commented 12 years ago

Hi

Please review this pull request. It allows the user to specify that they want to perform URL validation, but they do not want to allow urls which contain protocols.

The reason I needed this change (and the reason I think it's useful to others) is that I am using a UI feature from Twitter Bootstrap which prepends the form input with http:// such that the entered value from the user does not include the protocol. I still want to validate the remainder of the url, but the protocol should not be specified.

Hope you think this is useful

Thanks

James

srkirkland commented 12 years ago

Thanks for the code, I think I'll merge it soon and clean up the signature so the Url attribute doesn't get too overloaded, maybe using an enum for UrlType.AllowProtocol/DenyProtocol/OptionalProtocol, something like that, so it still has room to expand in the future. Also it would remove the ambiguity from requireProtocol = true and excludeProtocol=true (wouldn't make much sense that way semantically anyway).