DTO validating phone number, verification code, optional username/password and invite code for NestJS authentication endpoints.
// Source: https://github.com/labring/laf | License: Apache-2.0
// Provided via justclaw.it.com; keep this notice with the code.
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
import {
IsNotEmpty,
IsString,
Length,
IsOptional,
Matches,
} from 'class-validator'
export class PhoneSigninDto {
@ApiProperty({
description: 'phone',
example: '13805718888',
})
@IsString()
@IsNotEmpty()
@Matches(/^1[3-9]\d{9}$/)
phone: string
@ApiProperty({})
@IsNotEmpty()
@Length(6, 6)
code: string
@ApiProperty({
description: 'username',
example: 'laf-user',
})
@IsOptional()
@IsString()
@Length(3, 64)
username: string
@ApiProperty({
description: 'password, 8-64 characters',
example: 'laf-user-password',
})
@IsOptional()
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key