Skip to content

Handle length validator with procs, improve validators support#1859

Merged
carlosantoniodasilva merged 4 commits intomainfrom
ca-validator-length-proc
Jan 5, 2026
Merged

Handle length validator with procs, improve validators support#1859
carlosantoniodasilva merged 4 commits intomainfrom
ca-validator-length-proc

Conversation

@carlosantoniodasilva
Copy link
Copy Markdown
Member

@carlosantoniodasilva carlosantoniodasilva commented Jan 3, 2026

Devise changed their password validations to use a proc for
minimum/maximum for additional customization, but that apparently broke
SimpleForm minlength/maxlength logic since it wasn't handling that.

Instead of implementing it custom by checking for the value responding
to call like we do for a couple of other validators, I went with the
route of copying over the resolve_value implementation added to Rails
7.1 that handles all the possible scenarios for procs / send / etc,
which allows different ways of setting up the proc.

Expand usage of the shared resolve_value implementation across
the board, so other validations like numericality and format apply the
same logic to better match Rails behavior.

Closes #1858

Devise changed their password validations to use a proc for
minimum/maximum for additional customization, but that apparently broke
SimpleForm minlength/maxlength logic since it wasn't handling that.

Instead of implementing it custom by checking for the value responding
to `call` like we do for a couple of other validators, I went with the
route of copying over the `resolve_value` implementation added to Rails
7.1 that handles all the possible scenarios for procs / send / etc,
which allows different ways of setting up the proc.

Closes #1858
The shared logic can be reused to handle numericality and format
validators as well, instead of custom handling for each, so it better
matches Rails own implementation.
It expects the record to be passed as argument to the proc. Rails 7.1
added the ability to pass a proc without any args.
@carlosantoniodasilva carlosantoniodasilva changed the title Handle length validator with procs Handle length validator with procs, improve validators support Jan 3, 2026
@carlosantoniodasilva carlosantoniodasilva merged commit 9dce1a0 into main Jan 5, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Password field maxlength (and maybe others) set incorrectly when using a proc

1 participant