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 min and max length #3701

Merged
merged 3 commits into from Sep 29, 2017
Merged

Add validation for min and max length #3701

merged 3 commits into from Sep 29, 2017

Conversation

heldersepu
Copy link
Contributor

This address some of the validation requested on Issue #993

@shockey shockey self-requested a review September 25, 2017 01:20
@@ -535,6 +549,16 @@ export const validateParam = (param, isXml) => {
let numberCheck = type === "number" && !validateNumber(value) // validateNumber returns undefined if the value is a number
let integerCheck = type === "integer" && !validateInteger(value) // validateInteger returns undefined if the value is an integer

if (maxLength) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth noting that 0 will fail this conditional, but I can't see why you'd ever want to set minLength: 0 or maxLength: 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ye, I think that might play a bigger role on PR #3703 but here is not relevant

Copy link
Contributor

Choose a reason for hiding this comment

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

I just discussed this with @webron - maxLength: 0 is funky, but valid, so that case needs to be handled 😄

minLength: 0, though, is not an issue, because nothing can be length < 0.

Copy link
Contributor

@shockey shockey left a comment

Choose a reason for hiding this comment

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

maxLength validation needs to account for the case where maxLength === 0.

I'll make these changes now.

@shockey
Copy link
Contributor

shockey commented Sep 29, 2017

Hey @heldersepu, I'm not able to push to your remote in order to change this PR. I think it has something to do with the source branch being master.

Here are the changes I was trying to apply, in patch format: maxlength-0-validation.patch.zip

Please apply the patch to your branch (git apply maxlength-0-validation.patch) and push it 😄

@shockey
Copy link
Contributor

shockey commented Sep 29, 2017

Thanks @heldersepu!

@shockey shockey merged commit 67dbad4 into swagger-api:master Sep 29, 2017
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.

None yet

2 participants