Skip to content
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

validates User ID as a string #102

Closed
wants to merge 2 commits into from

Conversation

rashidsp
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Apr 17, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 9d07522 on rashid/user-id-string-validation into 619f3bc on master.

@@ -135,8 +135,8 @@ def get_variation(experiment_key, user_id, attributes = nil)
return nil
end

if user_id.to_s.empty?
@logger.log(Logger::ERROR, 'User ID cannot be empty.')
if !user_id.is_a?(String) || user_id.empty?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This same logic is duplicated in a few places. Can you create a validator function that we re-use?

@rashidsp
Copy link
Contributor Author

@mikeng13 Please review changes.
NOTE: This validator is only validates 'user_id'. However all inputs validator is implemented in different branch.

@@ -18,6 +18,7 @@
require_relative 'constants'
require 'json'
require 'json-schema'
require 'optimizely/logger'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a relative require since this module is in the Optimizely module?

@@ -306,6 +306,12 @@ module Constants
'INTEGER' => 'integer',
'STRING' => 'string'
}.freeze

INPUT_VARIABLES = {
'user_id' => 'User ID',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at VARIABLE_TYPES the keys are all caps. Let's keep it consistent here.

@mikeproeng37
Copy link
Contributor

build

@rashidsp
Copy link
Contributor Author

@mikeng13 All inputs validation is implemented in PR- #103
You may close this PR and review the other one.

@mikeproeng37 mikeproeng37 deleted the rashid/user-id-string-validation branch June 27, 2018 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants