How to use the class-validator.IsEnum function in class-validator

To help you get started, we’ve selected a few class-validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackoregon / openelections / api / controller / contributions.ts View on Github external
@IsOptional()
    amount: number;

    @IsString()
    @IsOptional()
    city: string;

    @IsString()
    @IsOptional()
    state: string;

    @IsString()
    @IsOptional()
    zip: string;

    @IsEnum(ContributorType)
    @IsOptional()
    contributorType: ContributorType;

    @IsString()
    @IsOptional()
    email: string;

    @IsString()
    @IsOptional()
    firstName: string;

    @IsString()
    @IsOptional()
    lastName: string;

    @IsString()
github mentos1386 / lynx / src / modules / user / user.validations.ts View on Github external
export class VPasswordReset {
  @ApiModelProperty()
  @IsDefined() @IsString() @Length(6)
  password: string;
  @ApiModelProperty()
  @IsDefined() @IsString()
  token: string;
}

export class VUserQuery {
  @ApiModelProperty()
  @IsString()
  search: string;

  @ApiModelProperty()
  @IsString() @IsEnum(USER_ROLE)
  role: USER_ROLE;

  @ApiModelProperty()
  @IsBoolean() @ToBoolean()
  blocked: boolean;
}

export class VBlocked {
  @ApiModelProperty()
  @IsBoolean()
  blocked: boolean;
}

export class VChangeUserRole {
  @ApiModelProperty()
  @IsString() @IsEnum(USER_ROLE)
github xmlking / ngx-starter-kit / apps / api / src / app / notifications / notification / dto / create-notification.dto.ts View on Github external
readonly title: string;

  @IsNotEmpty()
  @IsString()
  @MinLength(10)
  @MaxLength(100)
  readonly body: string;

  @IsNotEmpty()
  @IsAscii()
  @MinLength(3)
  @MaxLength(50)
  readonly target: string;

  @IsNotEmpty()
  @IsEnum(TargetType)
  readonly targetType: TargetType;

  @IsOptional()
  @IsEnum(NotificationIcon)
  readonly icon?: NotificationIcon = NotificationIcon.NOTIFICATIONS;

  @IsOptional()
  @IsEnum(NotificationColor)
  readonly color?: NotificationColor = NotificationColor.PRIMARY;

  @IsOptional()
  @IsBoolean()
  readonly native?: boolean = false;
}
github shanmugharajk / react-point-of-sale / api / src / entity / CreditTransactions.ts View on Github external
@IsNumber()
  @Min(0)
  @Column({ type: "float", nullable: true })
  billAmount?: number;

  @IsPositive()
  @Column({ type: "float" })
  amountPaid: number;

  @Column({ type: "float" })
  balance: number;

  @Column({ type: "float" })
  totalDebt: number;

  @IsEnum(CreditTransactionsType)
  @Column()
  type: CreditTransactionsType;

  @IsNotEmpty()
  @Column()
  paidDate: Date;

  @Column() isReverted: boolean;
}
github hackoregon / openelections / api / controller / expenditures.ts View on Github external
@IsOptional()
    state: string;

    @IsString()
    @IsOptional()
    zip: string;

    @IsString()
    @IsOptional()
    name: string;

    @IsEnum(PayeeType)
    @IsOptional()
    payeeType: PayeeType;

    @IsEnum(ExpenditureSubType)
    @IsOptional()
    subType: ExpenditureSubType;

    @IsEnum(ExpenditureStatus)
    @IsOptional()
    status: ExpenditureStatus;

    @IsEnum(ExpenditureType)
    @IsOptional()
    type: ExpenditureType;

    @IsNumber()
    @IsOptional()
    date: number;

    @IsEnum(PaymentMethod)
github xmlking / ngx-starter-kit / apps / api / src / app / notifications / notification / dto / create-notification.dto.ts View on Github external
@IsNotEmpty()
  @IsAscii()
  @MinLength(3)
  @MaxLength(50)
  readonly target: string;

  @IsNotEmpty()
  @IsEnum(TargetType)
  readonly targetType: TargetType;

  @IsOptional()
  @IsEnum(NotificationIcon)
  readonly icon?: NotificationIcon = NotificationIcon.NOTIFICATIONS;

  @IsOptional()
  @IsEnum(NotificationColor)
  readonly color?: NotificationColor = NotificationColor.PRIMARY;

  @IsOptional()
  @IsBoolean()
  readonly native?: boolean = false;
}
github shanmugharajk / react-point-of-sale / api / src / entity / User.ts View on Github external
@Entity()
export class User {
  @IsNotEmpty()
  @PrimaryColumn()
  id: string;

  @IsNotEmpty()
  @Column()
  name: string;

  @IsNotEmpty()
  @Column()
  password: string;

  @IsEnum(Role)
  @Column()
  role: Role;

  @IsNotEmpty()
  @CreateDateColumn()
  createdAt: Date;

  @IsNotEmpty()
  @UpdateDateColumn()
  updatedAt: Date;
}
github hackoregon / openelections / api / controller / contributions.ts View on Github external
@IsOptional()
    suffix: string;

    @IsString()
    @IsOptional()
    title: string;

    @IsBoolean()
    @IsOptional()
    submitForMatch: boolean;

    @IsEnum(ContributionSubType)
    @IsOptional()
    subType: ContributionSubType;

    @IsEnum(InKindDescriptionType)
    @IsOptional()
    inKindType: InKindDescriptionType;

    @IsEnum(ContributionType)
    @IsOptional()
    type: ContributionType;

    @IsEnum(OaeType)
    @IsOptional()
    oaeType: OaeType;

    @IsEnum(PaymentMethod)
    @IsOptional()
    paymentMethod: PaymentMethod;

    @IsNumber()
github hackoregon / openelections / api / controller / expenditures.ts View on Github external
@IsOptional()
    description: string;

    @IsString()
    @IsOptional()
    state: string;

    @IsString()
    @IsOptional()
    zip: string;

    @IsString()
    @IsOptional()
    name: string;

    @IsEnum(PayeeType)
    @IsOptional()
    payeeType: PayeeType;

    @IsEnum(ExpenditureSubType)
    @IsOptional()
    subType: ExpenditureSubType;

    @IsEnum(ExpenditureStatus)
    @IsOptional()
    status: ExpenditureStatus;

    @IsEnum(ExpenditureType)
    @IsOptional()
    type: ExpenditureType;

    @IsNumber()
github hackoregon / openelections / api / controller / contributions.ts View on Github external
@IsOptional()
    occupation: string;

    @IsString()
    @IsOptional()
    employerName: string;

    @IsString()
    @IsOptional()
    employerCity: string;

    @IsString()
    @IsOptional()
    employerState: string;

    @IsEnum(PhoneType)
    @IsOptional()
    phoneType: PhoneType;

    @IsString()
    @IsOptional()
    checkNumber: string;

    @IsString()
    @IsOptional()
    notes: string;

}

export async function addContribution(request: IRequest, response: Response, next: Function) {
    try {
        checkCurrentUser(request);