feat(utils): Introduce promiseAll util (#5543)

This commit is contained in:
Adrien de Peretti
2023-11-08 08:48:48 +01:00
committed by GitHub
parent e4ce2f4e07
commit f90ba02087
99 changed files with 464 additions and 297 deletions
@@ -9,6 +9,7 @@ import {
import { isDate } from "lodash"
import { MedusaError } from "medusa-core-utils"
import { validator } from "../validator"
import { promiseAll } from "@medusajs/utils"
async function typeValidator(
typedClass: any,
@@ -43,7 +44,7 @@ async function typeValidator(
if (isArray(typedClass) && isArray(plain)) {
const errors: Map<any, string> = new Map()
const result = (
await Promise.all(
await promiseAll(
(plain as any[]).map(
async (p) =>
await typeValidator(typedClass[0], p).catch((e) => {
@@ -80,7 +81,7 @@ export function IsType(types: any[], validationOptions?: ValidationOptions) {
validator: {
async validate(value: unknown, args: ValidationArguments) {
const errors: Map<any, string> = new Map()
const results = await Promise.all(
const results = await promiseAll(
types.map(
async (v) =>
await typeValidator(v, value).catch((e) => {