-
Notifications
You must be signed in to change notification settings - Fork 28
refact(API): Adds missing input validations in all API methods and validates empty user Id. #127
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
…lidates empty user Id.
build |
build |
lib/optimizely.rb
Outdated
}, @logger, Logger::ERROR | ||
) | ||
|
||
unless user_id.is_a?(String) |
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.
I'd rather we refactor a bit and avoid using this same logic everywhere in the code. Let's mimic what the C# SDK does here: https://github.com/optimizely/csharp-sdk/blob/master/OptimizelySDK/Optimizely.cs#L642
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.
Done.
it's ready for review. |
lib/optimizely.rb
Outdated
@@ -258,6 +258,8 @@ def is_feature_enabled(feature_flag_key, user_id, attributes = nil) | |||
}, @logger, Logger::ERROR | |||
) | |||
|
|||
return false unless user_inputs_valid?(attributes) |
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.
Can we combine Optimizely::Helpers::Validator.inputs_valid?
with user_inputs_valid?
? Seems like we could just put all user inputs into one dictionary and have them all validated
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.
Combined validations: rashid/input-validations...rashid/input-validations-2
It resulted in a big change plz confirm to continue with this PR?
Uh oh!
There was an error while loading. Please reload this page.