File tree 2 files changed +15
-12
lines changed
2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 95
95
load_time: Duration,
96
96
unload_time: Duration,
97
97
98
- mobility: enum ("ambulatory", "wheelchair")
98
+ mobility: enumeration ("ambulatory", "wheelchair")
99
99
}
100
100
101
101
darp_schema = {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ json_validate = (function () {
34
34
}
35
35
} ;
36
36
37
- function enum ( ) {
37
+ function enumeration ( ) {
38
38
var args = arguments ;
39
39
40
40
return function ( x )
@@ -108,24 +108,27 @@ json_validate = (function () {
108
108
return true ;
109
109
}
110
110
}
111
-
112
-
113
-
114
- for ( var item in schema )
111
+ for ( var item in object )
115
112
{
116
- //if (item == "depot") debugger;
117
- if ( schema . hasOwnProperty ( item ) )
113
+ if ( object . hasOwnProperty ( item ) )
118
114
{
119
- var constraint = schema [ item ] ;
120
- var value = object [ item ] ;
121
- var r = validate ( value , constraint ) ;
115
+ if ( ! schema . hasOwnProperty ( item ) ) {
116
+ var r = "not allowed here" ;
117
+ }
118
+ else {
119
+ var constraint = schema [ item ] ;
120
+ var value = object [ item ] ;
121
+ var r = validate ( value , constraint ) ;
122
+ }
123
+
122
124
if ( r !== true ) {
123
125
error = true ;
124
126
errors [ item ] = r ;
125
127
}
126
128
127
129
}
128
130
}
131
+
129
132
130
133
if ( error )
131
134
return errors ;
@@ -160,7 +163,7 @@ json_validate = (function () {
160
163
object : object ,
161
164
optional : optional ,
162
165
of : of ,
163
- enum : enum
166
+ enumeration : enumeration
164
167
}
165
168
166
169
return ret_fun ;
You can’t perform that action at this time.
0 commit comments