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

Add validation for username and rpm/tpm negative value #241

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

varungup90
Copy link
Collaborator

@varungup90 varungup90 commented Sep 26, 2024

@@ -54,6 +54,10 @@ func GetUser(u User, redisClient *redis.Client) (User, error) {
}

func SetUser(u User, redisClient *redis.Client) error {
if u.Rpm < 0 || u.Tpm < 0 {
return fmt.Errorf("rpm or tpm can not negative")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the http error to the client for this case now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

internal server error: 500

Copy link
Collaborator

Choose a reason for hiding this comment

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

should it be something like invalid argument? 400

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I will audit all endpoints and their return error codes.

@Jeffwan
Copy link
Collaborator

Jeffwan commented Sep 26, 2024

The challenge looks good to me and feel free to merge it.

@varungup90 varungup90 merged commit ffcc7a9 into main Sep 26, 2024
10 checks passed
@varungup90 varungup90 deleted the add-users-validation branch September 26, 2024 20:35
gangmuk pushed a commit that referenced this pull request Jan 25, 2025
* Add validation for username and rpm/tpm negative value

* update error code to 500
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.

2 participants