typeorm - id field is empty but there is a default value

40 Views Asked by At

I have this decorator code with typeorm:

@t.Entity('vibe_trace')
export class Trace extends From<Trace> {
 
  @t.ObjectIdColumn({nullable: false, default: () => new MongoId().toHexString()})
  @val.IsNotEmpty()
  @val.IsString()
  id!: string;

}

but I get this error:

 [
    ValidationError {
      children: [],
      constraints: {
        isNotEmpty: 'id should not be empty',
        isString: 'id must be a string'
      },

is there a good reason for this? default function must not be called

0

There are 0 best solutions below