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

feat: added new category field in obligations #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bhowmik94
Copy link

Changes

Submitter Checklist

  • Includes tests (if there is a feature changed/added)
  • Includes docs ( if changes are user facing)
  • I have tested my changes locally.

References

@@ -453,6 +477,11 @@ func (o *Obligation) BeforeUpdate(tx *gorm.DB) (err error) {
return fmt.Errorf("obligation classification must be one of the following values:%s", allClassifications)
}
}

if err := validateCategory(o); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I do not pass category while updating an obligation(I want to update other fields), internal server error is raised.
This shouldn't be the case.
image
image

@bhowmik94 bhowmik94 force-pushed the feat/api/categoryField-obligation branch from d2d163d to 38710ad Compare January 16, 2025 11:50
@@ -515,6 +539,11 @@ func (o *Obligation) BeforeUpdate(tx *gorm.DB) (err error) {
return fmt.Errorf("obligation classification must be one of the following values:%s", allClassifications)
}
}

if o.Category != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would you return error if o.Category is not nil?

You need to validate category field if it's not empty. It might be nil as it's a PATCH request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New field "Category" in obligations GET, PUT, POST
3 participants