Conversation
src/jesse_validator_draft4.erl
Outdated
| ?not_found -> | ||
| case get_value(?DEFAULT, PropertySchema) of | ||
| ?not_found -> CurrentState; | ||
| Default -> check_default(PropertyName, PropertySchema, Default, CurrentState) |
There was a problem hiding this comment.
According to Elvis:
Line 382 is too long: Default -> check_default(PropertyName, PropertySchema, Default, CurrentState).
src/jesse_validator_draft3.erl
Outdated
| is_valid_default(Types, Default, State) | ||
| when is_list(Types) -> | ||
| check_default_for_type(Default, State) | ||
| andalso lists:any(fun(Type) -> is_type_valid(Default, Type, State) end, Types); |
There was a problem hiding this comment.
According to Elvis:
Line 1078 is too long: andalso lists:any(fun(Type) -> is_type_valid(Default, Type, State) end, Types);.
| ], | ||
|
|
||
| [ ?assertEqual({ok, Value} | ||
| ,jesse_schema_validator:validate(Schema, Value, []) |
There was a problem hiding this comment.
According to Elvis:
Missing space right "," on line 46
src/jesse_lib.erl
Outdated
|
|
||
| %% @doc check if json object is_empty. | ||
| -spec is_json_object_empty(Value :: any()) -> boolean(). | ||
| is_json_object_empty({struct, Value}) when is_list(Value) andalso Value =:= [] -> true; |
There was a problem hiding this comment.
According to Elvis:
Line 74 is too long: is_json_object_empty({struct, Value}) when is_list(Value) andalso Value =:= [] -> true;.
src/jesse_validator_draft3.erl
Outdated
| check_default_for_type(Default, State) -> | ||
| jesse_state:validator_option('use_defaults', State, false) | ||
| andalso (not jesse_lib:is_json_object(Default) | ||
| orelse jesse_state:validator_option('apply_defaults_to_empty_objects', State, false) |
There was a problem hiding this comment.
According to Elvis:
Line 1059 is too long: orelse jesse_state:validator_option('apply_defaults_to_empty_objects', State, false).
src/jesse_lib.erl
Outdated
| is_json_object_empty({Value}) when is_list(Value) andalso Value =:= [] -> true; | ||
| %% handle `jsx' empty objects | ||
| is_json_object_empty([{}]) -> true; | ||
| ?IF_MAPS(is_json_object_empty(Map) when erlang:is_map(Map) -> maps:size(Map) =:= 0;) |
There was a problem hiding this comment.
According to Elvis:
Line 78 is too long: ?IF_MAPS(is_json_object_empty(Map) when erlang:is_map(Map) -> maps:size(Map) =:= 0;).
src/jesse_validator_draft3.erl
Outdated
| , Value | ||
| , CurrentState | ||
| ); | ||
| Default -> check_default(PropertyName, PropertySchema, Default, CurrentState) |
There was a problem hiding this comment.
According to Elvis:
Line 357 is too long: Default -> check_default(PropertyName, PropertySchema, Default, CurrentState).
src/jesse_validator_draft4.erl
Outdated
| check_default_for_type(Default, State) -> | ||
| jesse_state:validator_option('use_defaults', State, false) | ||
| andalso (not jesse_lib:is_json_object(Default) | ||
| orelse jesse_state:validator_option('apply_defaults_to_empty_objects', State, false) |
There was a problem hiding this comment.
According to Elvis:
Line 1381 is too long: orelse jesse_state:validator_option('apply_defaults_to_empty_objects', State, false).
| ,jesse_schema_validator:validate(Schema, Value, []) | ||
| ) | ||
| , ?assertEqual({ok, Default} | ||
| ,jesse_schema_validator:validate(Schema, Value, Options) |
There was a problem hiding this comment.
According to Elvis:
Missing space right "," on line 49
src/jesse_state.erl
Outdated
| validator_option(Option, #state{validator_options=Options}) -> | ||
| proplists:get_value(Option, Options). | ||
|
|
||
| -spec validator_option(Option :: atom(), State :: state(), Default :: any()) -> any(). |
There was a problem hiding this comment.
According to Elvis:
Line 409 is too long: -spec validator_option(Option :: atom(), State :: state(), Default :: any()) -> any()..
| end. | ||
|
|
||
| %% @private | ||
| set_value(PropertyName, Value, State) -> |
There was a problem hiding this comment.
According to Xref:
jesse_validator_draft4:set_value/3calls undefined functionjesse_state:set_value/3
| jesse_state:remove_last_from_path(State). | ||
|
|
||
| %% @private | ||
| set_value(PropertyName, Value, State) -> |
There was a problem hiding this comment.
According to Xref:
jesse_validator_draft3:set_value/3calls undefined functionjesse_state:set_value/3
| jesse_state:validator_option(Option, State, Default). | ||
|
|
||
| %% @private | ||
| set_value(PropertyName, Value, State) -> |
There was a problem hiding this comment.
According to Xref:
jesse_validator_draft3:set_value/3calls undefined functionjesse_state:set_value/3
3a0f529 to
d29dd1c
Compare
src/jesse_state.erl
Outdated
| %% Includes | ||
| -include("jesse_schema_validator.hrl"). | ||
|
|
||
| -type extra_validator() :: fun((jesse:json_term(), state()) -> state()) | undefined. |
There was a problem hiding this comment.
According to Elvis:
Line 62 is too long: -type extra_validator() :: fun((jesse:json_term(), state()) -> state()) | undefined..
src/jesse_state.erl
Outdated
| -include("jesse_schema_validator.hrl"). | ||
|
|
||
| -type extra_validator() :: fun((jesse:json_term(), state()) -> state()) | undefined. | ||
| -type setter_fun() :: fun((jesse:json_path(), jesse:json_term(), jesse:json_term()) -> jesse:json_term()) | undefined. |
There was a problem hiding this comment.
According to Elvis:
Line 63 is too long: -type setter_fun() :: fun((jesse:json_path(), jesse:json_term(), jesse:json_term()) -> jesse:json_term()) | undefined..
src/jesse_state.erl
Outdated
| set_value(#state{setter_fun=undefined}=State, _Path, _Value) -> State; | ||
| set_value(#state{current_value=undefined}=State, _Path, _Value) -> State; | ||
| set_value(#state{setter_fun=Setter | ||
| ,current_value=Value |
There was a problem hiding this comment.
According to Elvis:
Missing space right "," on line 443
d29dd1c to
f9b0e7d
Compare
fb87e9f to
e7cabcd
Compare
f9b0e7d to
62abe42
Compare
e7cabcd to
07bafff
Compare
62abe42 to
628d5d0
Compare
src/jesse_schema_validator.hrl
Outdated
|
|
||
| -type error_list() :: list(). | ||
|
|
||
| -type external_validator() :: fun((jesse:json_term(), state()) -> state()) |
There was a problem hiding this comment.
According to Compiler:
type state() undefined
src/jesse_schema_validator.hrl
Outdated
| } | ||
| ). | ||
|
|
||
| -opaque options() :: #options{}. |
There was a problem hiding this comment.
According to Compiler:
opaque type options() is not exported
|
xref failed with exit status: 1 |
src/jesse_schema_validator.hrl
Outdated
| } | ||
| ). | ||
|
|
||
| -opaque options() :: #options{}. |
There was a problem hiding this comment.
According to Xref:
opaque type options() is not exported
|
compiler failed with exit status: 1 |
src/jesse_state.erl
Outdated
|
|
||
| -spec set_value(State :: state(), jesse:path(), jesse:json_term()) -> state(). | ||
| set_value(#state{setter_fun = undefined} = State, _Path, _Value) -> State; | ||
| set_value(#state{current_value = undefined} = State, _Path, _Value) -> State; |
There was a problem hiding this comment.
According to Compiler:
field current_value undefined in record state
src/jesse_state.erl
Outdated
| , Path | ||
| , NewValue | ||
| ) -> | ||
| State#state{current_value = Setter(Path, NewValue, Value)}. |
There was a problem hiding this comment.
According to Xref:
field current_value undefined in record state
| set_value(#state{setter_fun = undefined} = State, _Path, _Value) -> State; | ||
| set_value(#state{current_value = undefined} = State, _Path, _Value) -> State; | ||
| set_value( #state{setter_fun = Setter | ||
| , current_value = Value |
There was a problem hiding this comment.
According to Compiler:
field current_value undefined in record state
| , schema_loader_fun = LoaderFun | ||
| , external_validator = ExternalValidator | ||
| , setter_fun = SetterFun | ||
| , current_value = Value |
There was a problem hiding this comment.
According to Compiler:
field current_value undefined in record state
src/jesse_state.erl
Outdated
|
|
||
| -spec set_value(State :: state(), jesse:path(), jesse:json_term()) -> state(). | ||
| set_value(#state{setter_fun = undefined} = State, _Path, _Value) -> State; | ||
| set_value(#state{current_value = undefined} = State, _Path, _Value) -> State; |
There was a problem hiding this comment.
According to Xref:
field current_value undefined in record state
| SetterFun = proplists:get_value( setter_fun | ||
| , Options | ||
| ), | ||
| Value = proplists:get_value( with_value |
There was a problem hiding this comment.
According to Xref:
variable 'Value' is unused
| , current_value = Value | ||
| } = State | ||
| , Path | ||
| , NewValue |
There was a problem hiding this comment.
According to Compiler:
variable 'NewValue' is unused
|
FWIW it's late and this PR needs more care and attention, but I have pushed anyway in case someone else has the time and will to move this forward |
0ede0af to
4a1e1be
Compare
src/jesse_state.erl
Outdated
| , Path | ||
| , NewValue | ||
| ) -> | ||
| State#state{current_value = Setter(Path, NewValue, Value)}. |
There was a problem hiding this comment.
According to Xref:
field current_value undefined in record state
| , current_value = Value | ||
| } = State | ||
| , Path | ||
| , NewValue |
There was a problem hiding this comment.
According to Compiler:
variable 'NewValue' is unused
src/jesse_state.erl
Outdated
|
|
||
| %% @doc Getter for `current_value'. | ||
| -spec get_current_value(State :: state()) -> jesse:json_term(). | ||
| get_current_value(#state{current_value = Value}) -> Value. |
There was a problem hiding this comment.
According to Compiler:
variable 'Value' is unbound
| , schema_loader_fun = LoaderFun | ||
| , external_validator = ExternalValidator | ||
| , setter_fun = SetterFun | ||
| , current_value = Value |
There was a problem hiding this comment.
According to Compiler:
field current_value undefined in record state
| set_value(#state{setter_fun = undefined} = State, _Path, _Value) -> State; | ||
| set_value(#state{current_value = undefined} = State, _Path, _Value) -> State; | ||
| set_value( #state{setter_fun = Setter | ||
| , current_value = Value |
There was a problem hiding this comment.
According to Compiler:
field current_value undefined in record state
| SetterFun = proplists:get_value( setter_fun | ||
| , Options | ||
| ), | ||
| Value = proplists:get_value( with_value |
There was a problem hiding this comment.
According to Xref:
variable 'Value' is unused
src/jesse_state.erl
Outdated
|
|
||
| -spec set_value(State :: state(), jesse:path(), jesse:json_term()) -> state(). | ||
| set_value(#state{setter_fun = undefined} = State, _Path, _Value) -> State; | ||
| set_value(#state{current_value = undefined} = State, _Path, _Value) -> State; |
There was a problem hiding this comment.
According to Xref:
field current_value undefined in record state
src/jesse_state.erl
Outdated
|
|
||
| -spec set_value(State :: state(), jesse:path(), jesse:json_term()) -> state(). | ||
| set_value(#state{setter_fun = undefined} = State, _Path, _Value) -> State; | ||
| set_value(#state{current_value = undefined} = State, _Path, _Value) -> State; |
There was a problem hiding this comment.
According to Compiler:
field current_value undefined in record state
allows to set values during validation
persistence depends on setter_fun option
4a1e1be to
d842928
Compare
|
@andreineculau what was wrong with the original pull request and why is it failing this part? |
|
hey @andreineculau could you please let us know what the current status of this PR is? |
|
Status is that i have just started parental leave today so "if the gods allow" i will start closing down issues/PR soon one way or the other 🎉 |
|
@andreineculau congrats! :) |
subset of @lazedo 's #42
This change is