Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validating-saving.cr - before custom_validation #127

Closed
ghost opened this issue Sep 14, 2019 · 3 comments · Fixed by #128
Closed

validating-saving.cr - before custom_validation #127

ghost opened this issue Sep 14, 2019 · 3 comments · Fixed by #128

Comments

@ghost
Copy link

ghost commented Sep 14, 2019

Hello there,

I am not really facing an issue, so forgive me if I missed something. It is pretty minor.

I am writing a Save::Operation in which I want to validate an e-mail address. Following the example:

before validate_user_is_old_enough

, I would write it like this:

before validate_email

private def validate_email
  # ... some implementation
end

But then I get the following error: Error: undefined local variable or method 'validate_email' for SaveUser.class. Could it be that the before_save-hook should be used?

# before validate_email
before_save validate_email
@paulcsmith
Copy link
Member

Yes that is correct! It should be “before_save”

We can add a compile time error for “before” that tells people to use “before_save”

Let me know if you have any other questions

@paulcsmith
Copy link
Member

Also we need to update the guide. Thanks for pointing that out! I didn’t realize this was in the website repo when I first saw it

@ghost
Copy link
Author

ghost commented Sep 14, 2019

Great, thanks for your response! I'll let you guys know if I come across anything :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant