Skip to content

Commit a677c08

Browse files
committed
Update registration field guide (Fixes #472)
This shows gives an example of validating the field is not empty, but with a comment so the user has a hint about how to do custom validation.
1 parent 7f9404a commit a677c08

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

doc/guides/registration_field.rdoc

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ create account hook:
2626
enable :login, :logout, :create_account
2727

2828
before_create_account do
29-
# Validate presence of the name field
30-
unless name = param_or_nil("name")
29+
# Validate the name field. This example checks that it is not empty,
30+
# but you may want to have application specific checks.
31+
unless name = param("name").empty?
3132
throw_error_status(422, "name", "must be present")
3233
end
3334

@@ -52,8 +53,8 @@ You can then handle the new submitted field as follows:
5253
enable :login, :logout, :create_account
5354

5455
before_create_account do
55-
# Validate presence of the name field
56-
throw_error_status(422, "name", "must be present") unless param_or_nil("name")
56+
# Validate the name field
57+
throw_error_status(422, "name", "must be present") unless param("name").empty?
5758
end
5859

5960
after_create_account do

0 commit comments

Comments
 (0)