How to use the class-validator.NotContains 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 mikesparr / typescript-postgres-auth-example / src / services / flag / flag.dto.ts View on Github external
IsBoolean,
  IsJSON,
  NotContains,
  IsDefined,
  IsOptional,
} from "class-validator";
import { FlagType } from "./flag.entity";

/**
 * Data transfer object (DTO) with expected fields for creating flags
 */
class CreateFlagDto {

  @IsString()
  @IsDefined()
  @NotContains(" ", { message: "No spaces allowed (i.e. my.flag.key)"} )
  public key: string;

  @IsString()
  public name: string;

  @IsEnum(FlagType)
  @IsOptional()
  public type: string;

  @IsString()
  @IsOptional()
  public description: string;

  @IsString()
  @IsOptional()
  public product: string;
github mikesparr / typescript-postgres-auth-example / src / services / user / user.dto.ts View on Github external
@IsString()
  @IsOptional()
  public firstName: string;

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

  @IsEmail()
  @IsDefined()
  public email: string;

  @IsString()
  @MinLength(8)
  @MaxLength(48)
  @NotContains(" ", { message: "No spaces allowed" } )
  @IsOptional()
  public password: string;

  @IsUrl()
  @IsOptional()
  public avatar: string;

  @IsString({ message: "Use a valid 2-digit country code (i.e. US)" })
  @MinLength(2)
  @MaxLength(2)
  @IsOptional()
  public country: string;

  @IsString()
  @IsOptional()
  public timeZone: string;
github mikesparr / typescript-postgres-auth-example / src / services / authentication / login.dto.ts View on Github external
IsDefined,
} from "class-validator";

/**
 * Data transfer object (DTO) with expected fields for user login
 */
class UserLoginDto {

  @IsEmail()
  @IsDefined()
  public email: string;

  @IsString()
  @MinLength(8)
  @MaxLength(24)
  @NotContains(" ", { message: "No spaces allowed" } )
  @IsDefined()
  public password: string;

}

export default UserLoginDto;
github mikesparr / typescript-postgres-auth-example / src / services / flag / goal.dto.ts View on Github external
IsBoolean,
  IsNumber,
  IsDefined,
  IsOptional,
  IsDate,
  NotContains,
} from "class-validator";

/**
 * Data transfer object (DTO) with expected fields for creating goals
 */
class CreateGoalDto {

  @IsString()
  @IsDefined()
  @NotContains(" ", { message: "No spaces allowed (i.e. my-goal-key)" } )
  public key: string;

  @IsString()
  public name: string;

  @IsNumber()
  @IsOptional()
  public hits: number;

  @IsNumber()
  @IsOptional()
  public uniqueUsers: number;

  @IsNumber()
  @IsOptional()
  public targetHits: number;
github penta-jelly / re-radio / server / src / radio / stations / dto / StationUpdateInput.dto.ts View on Github external
import { IsOptional, Length, NotContains, ValidateNested } from 'class-validator';
import {
  StationTagUpdateManyWithoutStationsInput,
  StationUpdateInput,
  StationWhereUniqueInput,
  UserRoleUpdateManyWithoutStationInput,
} from 'prisma/prisma.binding';

export class StationUpdateDTO implements StationUpdateInput {
  @Length(2, 32)
  @IsOptional()
  name?: string;

  @Length(2, 32)
  @IsOptional()
  @NotContains(' ')
  slug?: string;

  @IsOptional()
  description?: string;

  tags?: StationTagUpdateManyWithoutStationsInput;
  userRoles?: UserRoleUpdateManyWithoutStationInput;
}

export class StationUpdateInputDTO {
  @ValidateNested()
  @Type(() => StationUpdateDTO)
  data: StationUpdateDTO;

  where: StationWhereUniqueInput;
}
github penta-jelly / re-radio / server / src / radio / station / station.input.ts View on Github external
@Field(type => StationTagCreateInput, { nullable: true })
  @ValidateNested({ each: true })
  @Type(() => StationTagCreateInput)
  tags?: StationTagCreateInput[];
}

@InputType()
export class StationUpdateInput {
  @Field({ nullable: true })
  @MaxLength(64)
  @IsOptional()
  name?: string;

  @Field({ nullable: true })
  @NotContains(' ')
  @IsOptional()
  slug?: string;

  @Field({ nullable: true })
  @MaxLength(256)
  @IsOptional()
  description?: string;
}
github penta-jelly / re-radio / server / src / radio / stations / dto / StationCreateInput.dto.ts View on Github external
import { Type } from 'class-transformer';
import { IsOptional, Length, NotContains, ValidateNested } from 'class-validator';
import {
  StationCreateInput,
  StationTagCreateManyWithoutStationsInput,
  UserRoleCreateManyWithoutStationInput,
} from 'prisma/prisma.binding';

export class StationCreateDTO implements StationCreateInput {
  @Length(2, 32)
  name: string;

  @Length(2, 32)
  @NotContains(' ')
  slug: string;

  @IsOptional()
  description?: string;

  tags?: StationTagCreateManyWithoutStationsInput;
  userRoles?: UserRoleCreateManyWithoutStationInput;
}

export class StationCreateInputDTO {
  @ValidateNested()
  @Type(() => StationCreateDTO)
  data: StationCreateDTO;
}
github penta-jelly / re-radio / server / src / radio / stations / dto / StationUpdateManyInput.dto.ts View on Github external
import { Type } from 'class-transformer';
import { IsOptional, Length, NotContains, ValidateNested } from 'class-validator';
import { StationUpdateManyDataInput, StationWhereInput } from 'prisma/prisma.binding';

export class StationUpdateManyDTO implements StationUpdateManyDataInput {
  @Length(2, 32)
  @IsOptional()
  name?: string;

  @Length(2, 32)
  @IsOptional()
  @NotContains(' ')
  slug?: string;

  @IsOptional()
  description?: string | null;
}

export class StationUpdateManyInputDTO {
  @ValidateNested()
  @Type(() => StationUpdateManyDTO)
  data: StationUpdateManyDTO;

  where?: StationWhereInput;
}
github mgm-interns / team-radio / server / src / entities / station / Station.ts View on Github external
import { IsBoolean, IsNotEmpty, IsNumber, IsOptional, MaxLength, MinLength, NotContains } from 'class-validator';
import { User } from 'entities';
import { TimestampScalar } from 'scalars';
import slugify from 'slugify';
import { Field, ObjectType } from 'type-graphql';
import { Column, Entity } from 'typeorm';
import { BaseEntity } from '../BaseEntity';
import { UserRole } from '../user';

@ObjectType()
@Entity({ name: 'stations' })
export class Station extends BaseEntity {
  @NotContains(' ')
  @IsNotEmpty()
  @Field()
  @Column()
  stationId: string;

  @IsNotEmpty()
  @MinLength(2)
  @MaxLength(32)
  @Field()
  @Column()
  stationName: string;

  @Field(type => TimestampScalar)
  @Column()
  createdAt: number = Date.now();
github mikesparr / typescript-postgres-auth-example / src / services / flag / segment.dto.ts View on Github external
IsNumber,
  IsJSON,
  IsArray,
  IsDefined,
  IsOptional,
  NotContains,
} from "class-validator";

/**
 * Data transfer object (DTO) with expected fields for creating roles
 */
class CreateSegmentDto {

  @IsString()
  @IsDefined()
  @NotContains(" ", { message: "No spaces allowed (i.e. my-segment-key)"} )
  public key: string;

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

  @IsArray()
  @IsOptional()
  public included: number[] | string[];

  @IsArray()
  @IsOptional()
  public excluded: number[] | string[];

  @IsJSON()
  @IsOptional()