-
Notifications
You must be signed in to change notification settings - Fork 31
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
Cloak.Ecto.SHA256.hash_string/1
break when the value is nil
#53
Comments
This is my solution for the issue: changeset
|> get_field(:contact_email)
|> case do
nil ->
changeset
email ->
put_change(changeset, :contact_email_hash, email)
end |
Thanks @vitalis this resolves the issue when the If I'm not mistaken |
- See danielberkompas#53 - Check for nil values in `equal?/2` to avoid call `String.valid/1` on nil
@SimonLab |
First of all thank you for the recent release!
I've noticed some of my tests are failing due to:
cloak_ecto/lib/cloak_ecto/types/sha_256.ex
Lines 78 to 86 in 05ea920
I have a schema similar to
I can create a new changeset from this schema, however the initial value will be
nil
for:token_hash
.If I then call the following:
put_change(changeset, :token_hash, "my_token")
theString.valid?(nil)
inhash_string(string)
will fail.I'm not entirely sure if a check needs to be added in the
hash_string
function to make sure first the value are notnil
, or if I need to make sure first the changeset contains a valid string for the hash first.One way I can resolve this is to add a default empty string value to
field(:token_hash, Cloak.Ecto.SHA256, default: "")
.Let me know if this is a non issue and feel free to close this.
Thanks
The text was updated successfully, but these errors were encountered: