From bc8399c362534cb8215c4bb272fd66c870f9a9bc Mon Sep 17 00:00:00 2001 From: Rijk van Zanten Date: Fri, 21 May 2021 12:30:13 -0400 Subject: [PATCH] Fix validation short circuit on _or (#5806) * Fix _or validation step when in nested context Fixes #5405 * Add changeset --- .changeset/thick-flowers-burn.md | 5 +++++ api/src/services/authorization.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/thick-flowers-burn.md diff --git a/.changeset/thick-flowers-burn.md b/.changeset/thick-flowers-burn.md new file mode 100644 index 0000000000..e39396a609 --- /dev/null +++ b/.changeset/thick-flowers-burn.md @@ -0,0 +1,5 @@ +--- +'directus': patch +--- + +Fix an issue where the validation system could short-circuit when using \_or statements. diff --git a/api/src/services/authorization.ts b/api/src/services/authorization.ts index 8d9c92a69a..e1fb861d08 100644 --- a/api/src/services/authorization.ts +++ b/api/src/services/authorization.ts @@ -274,7 +274,8 @@ export class AuthorizationService { const nestedErrors = flatten( subValidation.map((subObj: Record) => this.validateJoi(subObj, payload)) ); - const allErrored = nestedErrors.every((err?: FailedValidationException) => err); + + const allErrored = subValidation.length === nestedErrors.length; if (allErrored) { errors.push(...nestedErrors);