the cool part here is that it is easy to combine validations for various use cases. here's an example for "Change password" where you keep the same password if you don't fill in any password:

(syntax may be subject to change)

and it's easy to refactor and support multiple use cases. maybe you have a page where you *must* change the password. ta-da:

ChangePassword = form(…) | match_with { }
MaybeChangePassword = continue_if { … } | ChangePassword

and maybe you have multiple forms on one page? well, it trivially supports both nested:

form(user_info: form(…), account_info: form(…))

and merged:

form(…) & form(…)

and nothing is form specific either. you can validate a single string if you want:

(trim | required | integer).validate(" 123 ").value # => 123

@judofyr This looks fantastic! It has a big FP feel to it. The fun parts, not the weird parts. :-)

@jgaskins it's beginning to fall into place now. this is based on ideas I've had floating around in various projects for years.

Sign in to participate in the conversation

A Mastodon instance for Rubyists & friends