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

"length" validation should add "required" attribute automatically #18

Open
kv109 opened this issue Nov 5, 2015 · 4 comments
Open

"length" validation should add "required" attribute automatically #18

kv109 opened this issue Nov 5, 2015 · 4 comments

Comments

@kv109
Copy link
Contributor

kv109 commented Nov 5, 2015

Hi!

I've noticed that

validates :first_name, length: { minimum: 2, maximum: 50 }

translates to

<input maxlength="50" minlength="2" size="50" type="text">

To be 100% accurate with actual model validation, it should translate to
<input required="required" maxlength="50" minlength="2" size="50" type="text">

If you agree, I could prepare a pull request with that, are you interested?

@amatsuda
Copy link
Owner

amatsuda commented Jan 5, 2016

@kv109 Ah, yes. I agree. Are you still willing to work on a PR?

@kv109
Copy link
Contributor Author

kv109 commented Jan 5, 2016

@amatsuda Not really. I wanted you to merge my another PR first (you just did). But I have something different. On my own fork I did simple handling of :if and :unless options. Code is messy, since it was written just for my team, but I could rewrite it. It was helpful for us since we have a lot of validations with simple :if and :unless conditions. Let me know if you would be interested.

@Ana06
Copy link

Ana06 commented Apr 24, 2019

what is the state of this? 🤔

@EdSF
Copy link

EdSF commented Jun 20, 2019

I haven't installed this gem and just reading through issues before I do.

Unfortunately have to disagree on this...it's a narrow/opinionated use case. If you want both required and string length validation, they should be separate (separate/distinct use cases).

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

No branches or pull requests

4 participants