Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@Field(type => String, {
nullable: true,
description: 'Paginate before opaque cursor',
})
@ValidateIf(o => o.before !== undefined)
@Validate(CannotUseWithout, ['last'])
@Validate(CannotUseWith, ['after', 'first'])
before?: Relay.ConnectionCursor;
@Field(type => String, {
nullable: true,
description: 'Paginate after opaque cursor',
})
@ValidateIf(o => o.after !== undefined)
@Validate(CannotUseWithout, ['first'])
@Validate(CannotUseWith, ['before', 'last'])
after?: Relay.ConnectionCursor;
@Field(type => Int, { nullable: true, description: 'Paginate first' })
@ValidateIf(o => o.first !== undefined)
@Min(1)
@Validate(CannotUseWith, ['before', 'last'])
first?: number;
@Field(type => Int, { nullable: true, description: 'Paginate last' })
@ValidateIf(o => o.last !== undefined)
// Required `before`. This is a weird corner case.
// We'd have to invert the ordering of query to get the last few items then re-invert it when emitting the results.
// We'll just ignore it for now.
@Validate(CannotUseWithout, ['before'])
@Validate(CannotUseWith, ['after', 'first'])
@Min(1)
import { Validate, IsNotEmpty, MaxLength, Min, Max, IsOptional } from 'class-validator';
import { plainToClassFromExist } from 'class-transformer';
import { TextLengthMore15 } from '../utils/custom-validators';
export class Company {
static strings = {
id: 'Id',
name: 'Name',
regionNum: 'Region num'
};
id: number;
@Validate(TextLengthMore15, {
message: 'The company name must be longer than 15'
})
@IsNotEmpty()
@MaxLength(20)
name: string;
@IsOptional()
@Min(1)
@Max(99)
regionNum: number;
toString() {
const arr: string[] = [];
if (arr.length === 0 && this.name) {
arr.push(this.name);
}
export class Project {
id?: number = undefined;
@IsNotEmpty({
groups: [ProjectPanelStepsEnum.Step1]
})
name?: string = undefined;
@IsNotEmpty({ always: true })
description?: string = undefined;
@ValidateNested({
groups: [ProjectPanelStepsEnum.Step2]
})
@Validate(ObjectMustBeNotEmpty, [1, 3], {
groups: [ProjectPanelStepsEnum.Step2],
message: 'Tasks not initialized or min length = 1 and max length = 3, and all initialized tasks must be not empty'
})
@IsOptional()
@Type(serializeModel(Task))
tasks?: Task[] = [];
toString() {
return `Project #${this.id} ${this.name}`;
}
}
public id: string;
@ApiModelProperty()
@IsString()
@Column()
public first_name: string;
@ApiModelProperty()
@IsString()
@Column()
public last_name: string;
@ApiModelProperty()
@IsEmail()
@ValidateIf(o => !o.id)
@Validate(IsUserAlreadyExist, {
message: 'User already exists'
})
@Column()
public email: string;
@ApiModelProperty()
@IsString()
@IsOptional()
@Column()
public phone_num: string;
@ApiModelProperty()
@IsOptional()
@IsUrl()
@Column()
public profile_img: string;
import { IsEmail, IsNotEmpty, IsString, Length, Validate } from 'class-validator';
import { IsEmailUnique } from '../validator/is-email-unique.validator';
export class UpdateUserDto {
@IsString()
@IsNotEmpty()
readonly firstName: string;
@IsString()
@IsNotEmpty()
readonly lastName: string;
@IsEmail()
@IsNotEmpty()
@Length(10, 100)
@Validate(IsEmailUnique)
readonly email: string;
}
import { Validate, IsNotEmpty, Min, Max, MaxLength, IsOptional } from 'class-validator';
import { TextLengthMore15 } from '../utils/custom-validators';
export class ExpCompany {
id: number;
@Validate(TextLengthMore15, {
groups: ['user'],
message: 'The company name must be longer than 15'
})
@IsNotEmpty({
groups: ['user']
})
@MaxLength(20)
name: string;
@IsOptional()
@Min(1)
@Max(99)
regionNum: number;
constructor(data?: any) {
if (data === undefined) {
import { IsAscii, IsEmail, IsNotEmpty, IsString, Length, Validate } from 'class-validator';
import { IsEmailUnique } from '../validator/is-email-unique.validator';
export class CreateUserDto {
@IsString()
@IsNotEmpty()
readonly firstName: string;
@IsString()
@IsNotEmpty()
readonly lastName: string;
@IsEmail()
@IsNotEmpty()
@Length(10, 100)
@Validate(IsEmailUnique)
readonly email: string;
@IsAscii()
@Length(8, 20)
@IsString()
@IsNotEmpty()
readonly username: string;
}
* all criteria are given
*
* @export
* @class UserUpdateRequest
* @extends {RequestBody}
*/
export class UserUpdateRequest extends RequestBody {
@IsNotEmpty()
public firstName: string;
@IsNotEmpty()
public lastName: string;
@IsEmail()
@Validate(EndsWithValidator, ['@gmail.com', '@w3tec.ch'])
public email: string;
@IsNotEmpty()
public picture: string;
@IsNotEmpty()
public auth0UserId: string;
/**
* We override the validate method so we can skip the missing
* properties.
*/
public validate(): Promise {
return super.validate(true);
}
@IsNotEmpty({
groups: [AuthModalTypeEnum.SignUp.toString()]
})
username: string = undefined;
@IsNotEmpty({
groups: [AuthModalTypeEnum.SignIn.toString(), AuthModalTypeEnum.SignUp.toString()]
})
@IsEmail(undefined, {
groups: [AuthModalTypeEnum.SignIn.toString(), AuthModalTypeEnum.SignUp.toString()]
})
email: string = undefined;
@IsNotEmpty({
groups: [AuthModalTypeEnum.SignIn.toString(), AuthModalTypeEnum.SignUp.toString()]
})
password: string = undefined;
@Validate(EqualsToOtherProperty, ['password'], {
groups: [AuthModalTypeEnum.SignUp.toString()]
})
@IsNotEmpty({
groups: [AuthModalTypeEnum.SignUp.toString()]
})
rePassword: string = undefined;
}
*
* @export
* @class UserCreateRequest
* @extends {RequestBody}
*/
export class UserCreateRequest extends RequestBody {
@IsNotEmpty()
public firstName: string;
@IsNotEmpty()
public lastName: string;
@IsNotEmpty()
@IsEmail()
@Validate(EndsWithValidator, ['@gmail.com', '@w3tec.ch'])
public email: string;
public picture: string;
public auth0UserId: string;
}