mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: remove unneseccary constraint validation request (#3914)
<!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> Fixes over-validating constraint ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # [1-949](https://linear.app/unleash/issue/1-949/fix-overvalidating-constraint) <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
864ef39d11
commit
84a3a4cb61
@ -16,9 +16,18 @@ export const useConstraintsValidation = (
|
||||
return;
|
||||
}
|
||||
|
||||
const validationRequests = constraints.map(constraint => {
|
||||
return validateConstraint(constraint);
|
||||
});
|
||||
const validationRequests = constraints
|
||||
.filter(constraint => {
|
||||
const hasValues =
|
||||
Array.isArray(constraint.values) &&
|
||||
constraint.values.length > 0;
|
||||
const hasValue = Boolean(constraint.value);
|
||||
|
||||
return hasValues || hasValue;
|
||||
})
|
||||
.map(constraint => {
|
||||
return validateConstraint(constraint);
|
||||
});
|
||||
|
||||
Promise.all(validationRequests)
|
||||
.then(() => setValid(true))
|
||||
|
Loading…
Reference in New Issue
Block a user