Nine Pomeranian Monsters

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

    Install

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

    DownloadsWeekly Downloads

    1,228

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    10.1 kB

    Total Files

    11

    Last publish

    Collaborators

    • michal.baran
    • alaa-awad
    • szymonszklarskijoin
    • sayda
    • oahmedqureshi
    • mohamedatta
    • kevincharecki
    • dlljoin
    • ashraaf.ateef
    • igocooper
    • yosri.mimouna
    • vitalii.pasiuta
    • pawelrozumek
    • elgayar
    • taciobelmonte
    • join-dev
    • pavlo.naumenko
    • ntnnk
    • adam187
    • favorit13
    • kirpichenkoo
    • tcichowicz
    • mayada
    • jakubspringer
    • boris.lapouga.join
    • readonly-user-join-com
    • cannoneer
    • lerbigdev
    • 12m3r