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

Fix useUnique send request even if the field value is empty #9334

Merged
merged 2 commits into from
Oct 6, 2023

Conversation

adguernier
Copy link
Contributor

@adguernier adguernier commented Oct 5, 2023

Problem

While using useUnique in an non required input, and when sending the form with empty value within this input, useUnique search for data with null value and returns results that indicates the record is not unique and indeed, cause errors on form.

This issue happens with some DBMS and DataProvider

Solution

Do not send request to the API if value tested by useUnique is empty.

Todo

  • use isEmpty function to check if the tested input is empty

@adguernier adguernier added WIP Work In Progress and removed RFR Ready For Review labels Oct 6, 2023
@@ -87,6 +87,9 @@ export const useUnique = (options?: UseUniqueOptions) => {
);

return async (value: any, allValues: any, props: InputProps) => {
if (!value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you extract and use 'isEmptyfromvalidate.ts` instead?

@djhi djhi added this to the 4.14.5 milestone Oct 6, 2023
@djhi djhi merged commit 24f286b into master Oct 6, 2023
9 checks passed
@djhi djhi deleted the fix-use-unique-send-request-even-tested-field-is-empty branch October 6, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants