html5_validators
html5_validators copied to clipboard
"length" validation should add "required" attribute automatically
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?
@kv109 Ah, yes. I agree. Are you still willing to work on a PR?
@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.
what is the state of this? :thinking:
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).