-
Notifications
You must be signed in to change notification settings - Fork 83
feature(API): Adds input validation in all API methods and validates empty user Id. #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@mfahadahmed this needs to be accompanied by a PR to change up the failing Compat Suite test. Please check it out. |
build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good mostly. I just have a coupla small suggestions
@@ -334,7 +334,8 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes) | |||
*/ | |||
Optimizely.prototype.setForcedVariation = function(experimentKey, userId, variationKey) { | |||
try { | |||
return projectConfig.setForcedVariation(this.configObj, experimentKey, userId, variationKey, this.logger); | |||
return this.__validateInputs({ experiment_key: experimentKey, user_id: userId }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nitpicky: explicitily return false if !this.__validateInputs...
and then keep the previous return value
@@ -368,6 +373,16 @@ Optimizely.prototype.getForcedVariation = function(experimentKey, userId) { | |||
*/ | |||
Optimizely.prototype.__validateInputs = function(stringInputs, userAttributes, eventTags) { | |||
try { | |||
// Empty user Id is valid value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to document what is NOT a valid value :)
No description provided.