Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Cases] Create and update case API guardrails for title, description, category, tags #160844
[Cases] Create and update case API guardrails for title, description, category, tags #160844
Changes from 14 commits
1e2fa9e
48479cf
9a559c4
01b5f7e
beba165
3e63edc
9deea3a
be13b94
c865f86
5b2a325
d8093ab
484a84b
719d163
943da11
dfcb2be
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
As we trim a lot in this function I think it is better if we put it on a variable. For example,
const trimedString = s.trim()
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.
Hmm do we want spaces to count as valid characters towards the min and max?
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 am assuming here that start and end of string spaces are unnecessary and should be removed before checking the length. But I am open if we want to keep it.
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 think it all depends on what we persist in ES. If we persist the spaces (which I think we are), then we should not trim. Or the other way around, if we think that we should trim (probably yes because we should not allow a title of only spaces), then we should trim before persisting it to ES. I lean towards trimming it to not allow titles with only empty spaces.
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.
It makes sense to me to trim for validation as well as before persisting to ES.
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.
Ok, let's leave the trimming but let's be consistent (not on this PR). In the UI for example no error is being shown in the case view page when you add an empty string to the title. In the backend, we do not trim before saving.