Skip to content

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

@leje512

Description

@leje512

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'
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions