Skip to content

null validation on post and patch methods #107

@ixxvivxxi

Description

@ixxvivxxi

json-api-nestjs: 9.0.0

Hi! When I'm trying to save entity with null value, I get an error Validation error: Expected string, received null at \"data.attributes.code\""
But in schema this column is nullable

@Entity({ name: 'countries' })
export class Countries extends CommonColumns {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'title', length: 250 })
  name: string;

  @Column({ length: 3, nullable: true, default: 'NULL' })
  code: string;
}

patch body:

{"data":{"id":"1","attributes":{"name":"test","code":null},"type":"countries"}}

I don't use any controllers for this entity, it is just imported into entities array in app.module

I think that worked in 8.*.* version , but I'm not sure, because I'm migrating from old data base and before I could sent an empty string.

Maybe I need to add a validation rule now?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions