From 461caaaed7a82aca4241963aef6dd88d941a9f89 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 21 Sep 2021 22:24:37 +0200 Subject: [PATCH] Changed filterValid to use getValidated instead of isValid and to reduce the valid values --- src/schemas/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 88fca9e..ec80339 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -254,5 +254,13 @@ export function filterValid( return []; } - return source.filter((current) => isValid(current, schema)); + return source.reduce((acc, current) => { + const validation = getValidated(current, schema); + + if (!validation) { + return acc; + } + + return [...acc, validation]; + }, []); }