validates_url | URL Validation for Rails | Validation library
kandi X-RAY | validates_url Summary
kandi X-RAY | validates_url Summary
URL Validation for Rails
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of validates_url
validates_url Key Features
validates_url Examples and Code Snippets
Community Discussions
Trending Discussions on validates_url
QUESTION
Use validates_url can validate url format.
Set validation in model:
...ANSWER
Answered 2018-Jan-09 at 14:05I do use rubular.com to validate using regex. You can try this ^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\.*)?$
QUESTION
I have a situation like that, I wanna check a field before save if it's a correct URL then save it, if not then change it to a correct way, my question is the validates function(regexp) is similar to Rails origin validates function, I don't wanna repeat it cause DRY principle, so is there any way can call the Rails validates alone?
I know I can do that by the way in below, but the syntax means check model with entire validates, so if other filed validate fail, it will change URL format, that's what I want, I wanna change URL format to correct format only when the URL format is not correct before save.
What's the best way to do it?
The one way I think ...ANSWER
Answered 2017-Apr-25 at 14:51test for the key :url
in errors after you check if record is valid.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install validates_url
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page