Skip to content

Commit

Permalink
#3287: properly validate 'string_types[0]'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff1evesque committed Oct 11, 2018
1 parent 4c6c0ec commit 8f8ad6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions brain/validator/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def validate_classification(self, data):

current_errors = []
schema = Schema({
Required('dependent-variable'): All(string_types, Length(min=1)),
Required('dependent-variable'): All(string_types[0], Length(min=1)),
Required('independent-variables'): [{
Required(All(string_types, Length(min=1))): Any(int, float),
Required(All(string_types[0], Length(min=1))): Any(int, float),
}],
})

Expand Down Expand Up @@ -70,7 +70,7 @@ def validate_regression(self, data):
schema = Schema({
Required('dependent-variable'): Any(int, float),
Required('independent-variables'): [{
Required(All(string_types, Length(min=1))): Any(int, float),
Required(All(string_types[0], Length(min=1))): Any(int, float),
}],
})

Expand Down
10 changes: 5 additions & 5 deletions brain/validator/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ def validate_settings(self, premodel_settings, session_type):
if session_type in ['data_new', 'data_append']:
if premodel_settings['stream'] == 'True' or session_type == 'data_new':
schema = Schema({
Required('collection'): All(string_types, Length(min=1)),
Required('collection'): All(string_types[0], Length(min=1)),
Required('dataset_type'): In(dataset_type),
Required('model_type'): In(model_type),
Required('session_type'): Any('data_new', 'data_append'),
Required('session_name'): All(string_types, Length(min=1)),
Required('session_name'): All(string_types[0], Length(min=1)),
Optional('stream'): Any('True', 'False'),
})

else:
schema = Schema({
Required('collection'): All(string_types, Length(min=1)),
Required('collection'): All(string_types[0], Length(min=1)),
Required('dataset_type'): In(dataset_type),
Required('model_type'): In(model_type),
Required('session_type'): Any('data_new', 'data_append'),
Expand All @@ -71,7 +71,7 @@ def validate_settings(self, premodel_settings, session_type):
# validation on 'model_generate' session
if session_type == 'model_generate':
schema = Schema({
Required('collection'): All(string_types, Length(min=1)),
Required('collection'): All(string_types[0], Length(min=1)),
Required('model_type'): In(model_type),
Required('session_type'): 'model_generate',
Optional('stream'): Any('True', 'False'),
Expand All @@ -83,7 +83,7 @@ def validate_settings(self, premodel_settings, session_type):
# validation on 'model_predict' session
elif session_type == 'model_predict':
schema = Schema({
Required('collection'): All(string_types, Length(min=1)),
Required('collection'): All(string_types[0], Length(min=1)),
Optional('stream'): Any('True', 'False'),
Required('prediction_input[]'): [
Any(Coerce(int), Coerce(float)),
Expand Down

0 comments on commit 8f8ad6a

Please sign in to comment.