You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a common pattern when using VirtualForms to yield the form object and one or more additional objects when the form is valid. For example:
classMyForm < Avram::VirtualForm
virtual some_field : Stringdefsubmit
validate_required some_field
if valid?
# Only yield the user if form is validyieldself, @userelseyieldself, nilendendend# Used like thisMyForm.submit do |form, user|
if user
# Do somethingelse# Do something elseendend
classRequestPasswordReset < Avram::VirtualOperation# You can modify this in src/operations/mixins/user_from_email.crincludeUserFromEmail
step validate_email
attribute email : Stringdefresult
user_from_email
enddefvalidate_email
validate_required email
if user_from_email?
email.add_error "is not in our system"endendend
The text was updated successfully, but these errors were encountered:
It is a common pattern when using
VirtualForms
to yield the form object and one or more additional objects when the form is valid. For example:This can get repetitive and error-prone.
Proposed solution
From comment here: #69 (comment)
An example of the
RequestResetPassword
operation. Original here (https://github.com/luckyframework/lucky_cli/blob/d78429c8e40f97af20437cb8199de51c4962159f/src/base_authentication_app_skeleton/src/operations/request_password_reset.cr#L1)The text was updated successfully, but these errors were encountered: