Changed filterValid to use getValidated instead of isValid and to reduce the valid values

This commit is contained in:
Alexander Cerutti
2021-09-21 22:24:37 +02:00
parent c49aad4098
commit 461caaaed7

View File

@@ -254,5 +254,13 @@ export function filterValid<T extends Object>(
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];
}, []);
}