class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

question: validate shows an unknown value was passed to the validate function even after creating the value

Open leje512 opened this issue 7 months ago • 0 comments

I'm not sure if I am using forbidUnknownValues wrong. After the default was set to true in the last release, i refactored my code to initialize the objects with typeorm and not as simple objects, but I still get the error: unknownValue: 'an unknown value was passed to the validate function'

This is how I normally create an entity with TypeORM:

const newPeriod = periodRepository.create({
     ...period,
     ...periodInput,
})

await validate(newPeriod)

and i also tried this version:

const period = new Period()

* assign all values to period: period.title = 'Period' .... */

await validate(period)

and this is the error I get in both versions:

ValidationError {
  target: Period {
    // values ...
  },
  value: undefined,
  property: undefined,
  children: [],
  constraints: {
    unknownValue: 'an unknown value was passed to the validate function'
  }
}

leje512 avatar Jul 14 '25 16:07 leje512