@join-com/typeorm-class-validator-is-uniq
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    75
    • latest

Version History

Package Sidebar

Install

npm i @join-com/typeorm-class-validator-is-uniq

Weekly Downloads

65

Version

2.0.0

License

MIT

Unpacked Size

10.1 kB

Total Files

11

Last publish

Collaborators

  • kamill-szymanski-join
  • shankaranloganathan
  • reza-join
  • sosodope
  • maciejlaszkiewicz
  • eugenetaran
  • denysov.kos
  • ddadonjoin
  • ibrahimsoomro
  • michal.baran
  • alaa-awad
  • szymonszklarskijoin
  • sayda
  • oahmedqureshi
  • mohamedatta
  • kevincharecki
  • dlljoin
  • ashraaf.ateef
  • yosri.mimouna
  • vitalii.pasiuta
  • join-dev
  • adam187
  • favorit13
  • kirpichenkoo
  • tcichowicz
  • mayada
  • jakubspringer
  • readonly-user-join-com
  • 12m3r