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

Move validations done in the user controllers into DTO #459

Merged
merged 9 commits into from
Dec 11, 2024

Conversation

divinecharlotte
Copy link
Contributor

Move validations done in the user controllers into DTO

Update user controller and move the validation logic to the DTO

Issue ticket #456 and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • No existing features have been broken without good reason.
  • The code style guideline have been followed
  • Documentation has been updated to reflect your changes.

@divinecharlotte divinecharlotte linked an issue Nov 25, 2024 that may be closed by this pull request
@divinecharlotte divinecharlotte changed the title Mofeat:ve validations done in the user controllers into DTO Move validations done in the user controllers into DTO Nov 27, 2024
Copy link
Contributor

@Kingcedru Kingcedru left a comment

Choose a reason for hiding this comment

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

Check all the validations and solve the conflicts

Comment on lines -153 to -158
if (userRegistrationData.orgName.trim() === '') {
throw new ConflictException({
success: false,
message: `orgName should not be 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 validation is not done because if I send an empty string with space inside it I don't get any error and the response becomes successful.
example:
{ "firstName": "babous", "lastName": "cedrus", "email": "babouce@gmail.com", "organizationType": "Buyer", "password": "King@123", "confirmPassword": "King@123", "orgName": " ", "orgAddress": "KN150" }

Comment on lines -140 to -152
if (
userRegistrationData.organizationType.toLowerCase() !=
'Buyer'.toLowerCase() &&
userRegistrationData.organizationType.toLowerCase() !=
'Developer'.toLowerCase() &&
userRegistrationData.organizationType.toLowerCase() !=
'ApiUser'.toLowerCase()
) {
throw new ConflictException({
success: false,
message: `organizationType value should be Developer/Buyer/ApiUser`,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This validation is not implemented because when I send an organizationType with buyer I get a forbidden error.

Example
{ "firstName": "babous", "lastName": "cedrus", "email": "babouce@gmail.com", "organizationType": "buyer", "password": "King@123", "confirmPassword": "King@123", "orgName": "BC group", "orgAddress": "KN150" }
response
{ "statusCode": 403, "message": "Forbidden resource", "error": "Forbidden" }

Kingcedru
Kingcedru previously approved these changes Nov 28, 2024
'Developer'.toLowerCase() &&
userRegistrationData.organizationType.toLowerCase() !=
'ApiUser'.toLowerCase()
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

here you have removed the validation to check if the organization type matches certain values and this validation wasn't added to the DTO

@musayann musayann merged commit 8a57c3b into develop Dec 11, 2024
9 checks passed
@musayann musayann deleted the ft/refactor-user-controller-validation branch December 11, 2024 13:51
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.

Move validations done in the user controllers into DTO
3 participants