Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
@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;
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;
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;
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;
}
@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;
}
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;
}
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;
}
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();
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()