2.0.0 • Published 3 years ago

@join-com/typeorm-class-validator-is-uniq v2.0.0

Weekly downloads
108
License
MIT
Repository
github
Last release
3 years ago

IsUniq validator

Custom validator for class-validator and typeorm

It validates uniqueness of any value across all records in a database. The validation can be narrowed down to a scope based on another column. It doesn't consider nulls as unique values to be compatible with SQL specification

Installation

npm install @join-com/typeorm-class-validator-is-uniq --save

Usage

You can use the validator as any other class-validator:

@Entity()
class User {
  @PrimaryGeneratedColumn()
  public id: string;

  // Validates uniqueness of an email across all records
  @IsUniq()
  @Column()
  public email: string;

  // Validates uniqueness of a department in scope of a company
  @IsUniq({ scope: ['company'] })
  @Column({ nullable: true })
  public department: string;

  @Column({ nullable: true })
  public company: string;
}
2.0.0

3 years ago

1.3.10

4 years ago

1.2.10

5 years ago

1.2.10-alpha.0

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.0

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago