Uh oh!
There was an error while loading. Please reload this page.
Client-side HTML 5 validations - #63
Conversation
bradgessler
commented
Mar 1, 2026
Thanks for putting this together, @andrewhwaller! This was the inspiration for #70, which takes the same idea further — it handles The main architectural difference is that #70 puts the validation inference on the Field (via a single I'm going to close this in favor of #70, though I should note that #70 is a draft and I'm going to let it sit for a while so I can think about the approach. No immediate plans to merge. Thanks again for kicking this off! |
andrewhwaller
commented
Mar 2, 2026
No problem, glad I could help! |
Spotted an issue for this (#46) and figured I'd take a crack at it!
This PR adds a
Requirableconcern that checks a form's underlying class for a presence validator on the relevant field (presence_validated?) and mergesrequired: trueinto the field's attributes if such a validation is detected. Ifrequired: falseis passed in, that value will be respected. I added the concern toCheckbox,Input,Select, andTextarea, since those are the field types that can take advantage ofrequired. I also added some specs covering theRequirablebehavior for all four.Note: I wasn't sure if a concern was the way to go here. Putting this logic directly in
Fieldfelt possibly weird, so I just went with a concern to keep things modular/contained.