File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 "keyword-spacing": ["warn", {"after": true}],
2020 "jsx-quotes": ["warn", "prefer-double"],
2121 "no-extra-boolean-cast": "off",
22- "no-console": 0,
2322 "no-multi-spaces": "warn",
2423 "no-spaced-func": "warn",
2524 "no-unused-vars": "warn",
Original file line number Diff line number Diff line change @@ -195,8 +195,11 @@ var Validation = function () {
195195 key : 'isFormValid' ,
196196 value : function isFormValid ( state ) {
197197 var storage = state [ this . validationStorageName ] ;
198+ if ( ( typeof state === 'undefined' ? 'undefined' : _typeof ( state ) ) !== 'object' ) {
199+ throw new Error ( 'Invalid state parameter, must be object' ) ;
200+ }
198201 if ( ( typeof storage === 'undefined' ? 'undefined' : _typeof ( storage ) ) !== 'object' ) {
199- throw new Error ( 'Invalid fieldsMappedToStatuses object, must be object' ) ;
202+ throw new Error ( 'Invalid storage object, must be object' ) ;
200203 }
201204
202205 var keys = Object . keys ( storage ) ;
@@ -219,13 +222,14 @@ var Validation = function () {
219222 key : 'isFieldValid' ,
220223 value : function isFieldValid ( state , fieldName ) {
221224 var storage = state [ this . validationStorageName ] ;
225+ if ( ( typeof state === 'undefined' ? 'undefined' : _typeof ( state ) ) !== 'object' ) {
226+ throw new Error ( 'Invalid state parameter, must be object' ) ;
227+ }
222228 if ( ( typeof storage === 'undefined' ? 'undefined' : _typeof ( storage ) ) !== 'object' ) {
223229 throw new Error ( 'Invalid storage object, must be object' ) ;
224230 }
225231 var fieldStatuses = storage [ fieldName ] ;
226232 if ( ! fieldStatuses ) {
227- // TODO: how to disable warnings in production
228- console . warn ( "Attempt to validate field that doesn't exist" ) ;
229233 return false ;
230234 }
231235
Original file line number Diff line number Diff line change @@ -208,8 +208,11 @@ class Validation {
208208
209209 isFormValid ( state : Object ) : boolean {
210210 const storage = state [ this . validationStorageName ] ;
211+ if ( typeof state !== 'object' ) {
212+ throw new Error ( 'Invalid state parameter, must be object' ) ;
213+ }
211214 if ( typeof storage !== 'object' ) {
212- throw new Error ( 'Invalid fieldsMappedToStatuses object, must be object' ) ;
215+ throw new Error ( 'Invalid storage object, must be object' ) ;
213216 }
214217
215218 const keys = Object . keys ( storage ) ;
@@ -228,13 +231,14 @@ class Validation {
228231
229232 isFieldValid ( state : Object , fieldName : string ) : boolean {
230233 const storage = state [ this . validationStorageName ] ;
234+ if ( typeof state !== 'object' ) {
235+ throw new Error ( 'Invalid state parameter, must be object' ) ;
236+ }
231237 if ( typeof storage !== 'object' ) {
232238 throw new Error ( 'Invalid storage object, must be object' ) ;
233239 }
234240 const fieldStatuses = storage [ fieldName ] ;
235241 if ( ! fieldStatuses ) {
236- // TODO: how to disable warnings in production
237- console . warn ( "Attempt to validate field that doesn't exist" ) ;
238242 return false ;
239243 }
240244
You can’t perform that action at this time.
0 commit comments