How to use the class-validator.Length 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 xmlking / ngx-starter-kit / apps / api / src / app / project / dto / find-projects.dto.ts View on Github external
@IsOptional()
  readonly createdBy?: User;

  @IsOptional()
  @IsString()
  readonly clusterName?: string;

  @IsOptional()
  @ArrayUnique()
  @IsString({ each: true })
  @Transform(value => (value ? value.split(',') : []))
  readonly groups?: string[];

  @IsOptional()
  @IsAscii()
  @Length(5, 100)
  @Matches(/^[a-z\d-]+$/)
  readonly namespace?: string;

  @IsOptional()
  @IsAscii()
  @Length(5, 100)
  @Matches(/^[a-z\d-]+$/)
  readonly serviceAccountName?: string;

  @IsOptional()
  @ValidateNested()
  @Type(() => Labels)
  readonly labels?: Labels;

  @Transform((val: string) => val === 'true')
  @IsOptional()
github mentos1386 / lynx / src / modules / user / user.validations.ts View on Github external
IsDefined,
  IsEmail, IsEnum,
  IsString,
  Length,
} from 'class-validator';
import { ApiModelProperty } from '@nestjs/swagger';
import { USER_ROLE } from './user.constants';
import { ToBoolean } from 'class-sanitizer';

export class VRegister {
  @ApiModelProperty()
  @IsDefined() @IsString()
  name: string;

  @ApiModelProperty()
  @IsDefined() @IsString() @Length(6)
  password: string;

  @ApiModelProperty()
  @IsDefined() @IsEmail()
  email: string;
}

export class VUpdatePassword {
  @ApiModelProperty()
  @IsDefined() @IsString() @Length(6)
  password: string;
}

export class VProfile {
  @ApiModelProperty()
  @IsEmail()
github ahrnee / nestjs-bff / packages / pkg-bff-global-contracts / src / domain / organization / organization.entity.ts View on Github external
import { BaseEntity } from '../core/base.entity';
import { Length } from 'class-validator';

export class OrganizationEntity extends BaseEntity {
  @Length(2, 50)
  name?: string;

  @Length(2, 50)
  slug?: string;
}
github te-emprego / api / src / modules / Users / methods / UpdateInfo.method.ts View on Github external
IsString,
  Length,
  validateOrReject,
  IsDate,
  ValidateNested
} from 'class-validator'

import { ModuleResponse } from '@interfaces'
import { ControllerMethod } from '@classes'

import UserModel from '../User.schema'
import { User, Address } from '../User.interface'

class InputValidation {
  @IsString()
  @Length(3, 255)
  public name: string

  @Length(9, 11)
  public phone: string

  @Length(0, 350)
  public avatar: string

  @IsDate()
  public birthdate: Date

  @ValidateNested()
  public address: Address
}

interface SanitizedProps {
github penta-jelly / re-radio / server / src / radio / users / dto / UserUpdateInput.dto.ts View on Github external
import { Type } from 'class-transformer';
import { IsEmail, IsOptional, IsUrl, Length, ValidateNested } from 'class-validator';
import { FileUpload } from 'graphql-upload';
import { UserRoleUpdateManyWithoutUserInput, UserUpdateInput, UserWhereUniqueInput } from 'prisma/prisma.binding';

export class UserUpdateDTO implements UserUpdateInput {
  @IsEmail()
  @Length(6, 64)
  email?: string;

  @Length(6, 32)
  @IsOptional()
  username?: string;

  @IsOptional()
  password?: string;

  @IsUrl()
  @IsOptional()
  coverUrl?: string;

  @IsUrl()
  @IsOptional()
  avatarUrl?: string;

  country?: string;
github ahrnee / nestjs-bff / packages / pkg-bff-global-contracts / src / application / auth / create-organization-member.command.ts View on Github external
import { IsEmail, IsNotEmpty, IsString, Length } from 'class-validator';
export class CreateOrganizationMemberCommand {
  @IsNotEmpty()
  public readonly orgId: string = '';

  @IsEmail()
  @Length(6, 64)
  public readonly username: string = '';

  @IsString()
  @Length(1, 32)
  public readonly displayName: string = '';

  @IsString()
  @Length(8, 64)
  public readonly password: string = '';
}
github ahrnee / nestjs-bff / packages / pkg-bff-global-contracts / src / application / auth / local-register.command.ts View on Github external
import { IsEmail, IsString, Length } from 'class-validator';

export class LocalRegisterCommand {
  @IsEmail()
  @Length(6, 64)
  public readonly username: string = '';

  @IsString()
  @Length(1, 32)
  public readonly displayName: string = '';

  @IsString()
  @Length(8, 32)
  public readonly password: string = '';
}
github penta-jelly / re-radio / server / src / radio / auth / dto / RegisterInput.dto.ts View on Github external
import { Type } from 'class-transformer';
import { IsEmail, IsNotEmpty, IsOptional, Length, ValidateNested } from 'class-validator';

export class RegisterDTO {
  @IsNotEmpty()
  @Length(6, 32)
  password: string;

  @IsEmail()
  @Length(6, 64)
  email: string;

  @Length(6, 32)
  @IsOptional()
  username?: string;
}

export class RegisterInputDTO {
  @ValidateNested()
  @Type(() => RegisterDTO)
  data: RegisterDTO;
}
github vellengs / nestx-server / packages / auth / src / dto / Register.dto.ts View on Github external
@MinLength(11)
  @IsString()
  mobile: string;

  @Length(5, 50)
  @IsString()
  @IsEmail()
  email: string;

  name?: string;

  @Length(2, 5)
  @IsOptional()
  mobilePrefix?: string;

  @Length(6)
  @IsNotEmpty()
  veryCode: string;
}