-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi @williamthome ,
I have following code
-module(model_user).
-export([changeset/1, changeset/2]).
-define(TYPES, #{
id => binary,
username => binary,
userpassword => binary,
role => binary,
created_at => tuple
}).
-define(PERMITTED_ALL_ATTR, maps:keys(?TYPES)).
-define(REQUIRED_ALL_ATTR, maps:keys(?TYPES)).
changeset(Params) ->
changeset(#{}, Params).
changeset(Data, Params) ->
Changeset = changeset:cast({Data, ?TYPES}, Params, ?PERMITTED_ALL_ATTR),
changeset:pipe(Changeset, [
changeset:validate_required(?REQUIRED_ALL_ATTR),
changeset:validate_member(role, [<<"ADMIN">>, <<"MITRA">>])
]).
Then when I do / execute the validation: model_user:changeset(#{}).
I only get 1 validation error: [{id,{<<"is required">>,#{validation => is_required}}}]
My expectation I get 5 validation error in total.
But I only get the following:
{changeset,[],
#{id => binary,role => binary,username => binary,
userpassword => binary,created_at => tuple},
[id,role,username,userpassword,created_at],
#{},#{},
[{id,{<<"is required">>,#{validation => is_required}}}], %% I only get 1 validation error. How to get all validation errors?
[undefined,<<>>]}
Thank you 🙏
Metadata
Metadata
Assignees
Labels
No labels