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

Fixed Validation error when empty default customfield values #11737

Conversation

inietov
Copy link
Collaborator

@inietov inietov commented Aug 25, 2022

Description

This builds over #11724, in that PR I eliminate the required rule if it exists, but then if an input is set as an empty string and another rule on the custom field look for a date or a custom regex or something like that, the validator still fails.

So in this one instead of remove the required rule I replace it with a nullable rule, to let pass the validator in such cases.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Test Configuration:

  • PHP version: 7.4.16
  • MySQL version: 8.0.23
  • Webserver version: nginx/1.19.8
  • OS version: Debian 10

Checklist:

@snipe
Copy link
Owner

snipe commented Aug 25, 2022

Do we need to do both? Remove required and also set to nullable?

@inietov
Copy link
Collaborator Author

inietov commented Aug 25, 2022

I think so. The way I understand it is that "nullable" is the inverse of "required". Line 86 in the function that sets the custom fields rules:
image

@snipe
Copy link
Owner

snipe commented Aug 25, 2022

Right, but in your code, it looks like you replaced removing required with adding nullable, so the $rules would be required|nullable, which seems weird? Unless I'm misreading?

@inietov
Copy link
Collaborator Author

inietov commented Aug 25, 2022

No because I'm overwriting the rule in that position. If the validation rules are:

0=>'required'
1=>'date'

It replaces it with:

0=>'nullable'
1=>'date'

@snipe
Copy link
Owner

snipe commented Aug 26, 2022

Thanks for the clarification!

@snipe snipe merged commit 96ec96f into snipe:develop Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants