#Issue in my NestJS backend with the financialSituation field

2 messages · Page 1 of 1 (latest)

tribal locust
#

"Hi all! I’m facing an issue in my NestJS backend with the financialSituation field — the backend expects a single value from a predefined list of choices, but sometimes I need to handle multiple, incompatible values at once. How can I properly manage or validate financialSituation when multiple, non-compatible options might be submitted?"

  • When I put multiple: true I have this err :
    {Argument financialSituation: Invalid value provided. Expected EnumFinancialSituationFilter or FinancialSituation, provided (String, String).}
    let [total, data] = include
    29 ? await Promise.all([
    → 30 model.count({
    select: {
    _count: {
    select: {
    _all: true
    }
    }
    },
    where: {
    financialSituation: [
    "REGULAR",
    "PENDING"
    ]

         }
       })
    
dapper shell
#

Hey! The error suggests that financialSituation expects a single enum value, not an array. If you need to filter by multiple enum values, wrap them in a filter using something like Prisma’s in operator (if you're using Prisma):

where: {
financialSituation: {
in: ["REGULAR", "PENDING"]
}
}

This way, your query checks if financialSituation matches any of the values in the list — and it won’t throw the enum error. Let me know what ORM or validation library you're using if you need a more tailored example!