Skip to content

Commit 2eba6a3

Browse files
committed
Revert "Merge pull request #51 from for-GET/pr-42-validator"
This reverts commit 7865bfc, reversing changes made to ef226b2.
1 parent 4160f98 commit 2eba6a3

File tree

5 files changed

+7
-42
lines changed

5 files changed

+7
-42
lines changed

src/jesse.erl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
-export_type([ allowed_errors/0
4141
, error_handler/0
4242
, error_list/0
43-
, external_validator/0
4443
, json_term/0
4544
, schema/0
4645
, schema_id/0
@@ -67,10 +66,6 @@
6766

6867
-type error_list() :: list().
6968

70-
%% -type external_validator() :: fun((json_term(), state()) -> state())
71-
-type external_validator() :: fun((json_term(), any()) -> any())
72-
| undefined.
73-
7469
-type json_term() :: term().
7570

7671
-type parser_fun() :: fun((json_term() | binary()) -> json_term()).
@@ -91,7 +86,6 @@
9186
-type option() :: {allowed_errors, allowed_errors()}
9287
| {default_schema_ver, schema_ver()}
9388
| {error_handler, error_handler()}
94-
| {external_validator, external_validator()}
9589
| {meta_schema_ver, schema_ver()}
9690
| {parser_fun, parser_fun()}
9791
| {schema_loader_fun, schema_loader_fun()}.

src/jesse_schema_validator.hrl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
-define(not_one_schema_valid, 'not_one_schema_valid').
122122
-define(not_schema_valid, 'not_schema_valid').
123123
-define(wrong_not_schema, 'wrong_not_schema').
124-
-define(external, 'external').
125124

126125
%%
127126
-define(not_found, 'not_found').

src/jesse_state.erl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
%% API
2727
-export([ add_to_path/2
2828
, get_allowed_errors/1
29-
, get_external_validator/1
3029
, get_current_path/1
3130
, get_current_schema/1
3231
, get_current_schema_id/1
@@ -58,7 +57,7 @@
5857
, default_schema_ver :: jesse:schema_ver()
5958
, error_handler :: jesse:error_handler()
6059
, error_list :: jesse:error_list()
61-
, external_validator :: jesse:external_validator()
60+
6261
, id :: jesse:schema_id()
6362
, root_schema :: jesse:schema()
6463
, schema_loader_fun :: jesse:schema_loader_fun()
@@ -139,9 +138,6 @@ new(JsonSchema, Options) ->
139138
, Options
140139
, ?default_error_handler_fun
141140
),
142-
ExternalValidator = proplists:get_value( external_validator
143-
, Options
144-
),
145141
LoaderFun = proplists:get_value( schema_loader_fun
146142
, Options
147143
, ?default_schema_loader_fun
@@ -153,7 +149,6 @@ new(JsonSchema, Options) ->
153149
, error_handler = ErrorHandler
154150
, default_schema_ver = DefaultSchemaVer
155151
, schema_loader_fun = LoaderFun
156-
, external_validator = ExternalValidator
157152
},
158153
set_current_schema(NewState, JsonSchema).
159154

@@ -388,7 +383,3 @@ load_schema(#state{schema_loader_fun = LoaderFun}, SchemaURI) ->
388383
%% io:format("load_schema: ~p\n", [{_C, _E, erlang:get_stacktrace()}]),
389384
?not_found
390385
end.
391-
392-
%% @private
393-
get_external_validator(#state{external_validator = Fun}) ->
394-
Fun.

src/jesse_validator_draft3.erl

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
| ?not_in_range
4949
| ?wrong_length
5050
| ?wrong_size
51-
| ?wrong_type
52-
| ?external.
51+
| ?wrong_type.
5352

5453
-type data_error_type() :: data_error()
5554
| {data_error(), binary()}.
@@ -210,11 +209,11 @@ check_value(Value, [{?DISALLOW, Disallow} | Attrs], State) ->
210209
check_value(Value, [{?EXTENDS, Extends} | Attrs], State) ->
211210
NewState = check_extends(Value, Extends, State),
212211
check_value(Value, Attrs, NewState);
212+
check_value(_Value, [], State) ->
213+
State;
213214
check_value(Value, [{?REF, RefSchemaURI} | Attrs], State) ->
214215
NewState = validate_ref(Value, RefSchemaURI, State),
215216
check_value(Value, Attrs, NewState);
216-
check_value(Value, [], State) ->
217-
maybe_external_check_value(Value, State);
218217
check_value(Value, [_Attr | Attrs], State) ->
219218
check_value(Value, Attrs, State).
220219

@@ -1032,12 +1031,3 @@ add_to_path(State, Property) ->
10321031
%% @private
10331032
remove_last_from_path(State) ->
10341033
jesse_state:remove_last_from_path(State).
1035-
1036-
%% @private
1037-
maybe_external_check_value(Value, State) ->
1038-
case jesse_state:get_external_validator(State) of
1039-
undefined ->
1040-
State;
1041-
Fun ->
1042-
Fun(Value, State)
1043-
end.

src/jesse_validator_draft4.erl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
| ?too_many_properties
6666
| ?wrong_length
6767
| ?wrong_size
68-
| ?wrong_type
69-
| ?external.
68+
| ?wrong_type.
7069

7170
-type data_error_type() :: data_error()
7271
| {data_error(), binary()}.
@@ -247,11 +246,11 @@ check_value(Value, [{?ONEOF, Schemas} | Attrs], State) ->
247246
check_value(Value, [{?NOT, Schema} | Attrs], State) ->
248247
NewState = check_not(Value, Schema, State),
249248
check_value(Value, Attrs, NewState);
249+
check_value(_Value, [], State) ->
250+
State;
250251
check_value(Value, [{?REF, RefSchemaURI} | Attrs], State) ->
251252
NewState = validate_ref(Value, RefSchemaURI, State),
252253
check_value(Value, Attrs, NewState);
253-
check_value(Value, [], State) ->
254-
maybe_external_check_value(Value, State);
255254
check_value(Value, [_Attr | Attrs], State) ->
256255
check_value(Value, Attrs, State).
257256

@@ -1363,11 +1362,3 @@ valid_datetime(DateTimeBin) ->
13631362
_ ->
13641363
false
13651364
end.
1366-
1367-
maybe_external_check_value(Value, State) ->
1368-
case jesse_state:get_external_validator(State) of
1369-
undefined ->
1370-
State;
1371-
Fun ->
1372-
Fun(Value, State)
1373-
end.

0 commit comments

Comments
 (0)