How to use the class-validator.IsEmail 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 rucken / core / libs / rucken / core / src / lib / entities / models / user.ts View on Github external
deleteMessage: translate('Do you really want to delete user?'),
    selectTitle: translate('Select user')
  };
  // need for deep update if local change in any place
  static nested = {
    groups: Group
  };
  id: number = undefined;
  @IsNotEmpty()
  username: string = undefined;
  password: string = undefined;
  rePassword: string = undefined;
  firstName: string = undefined;
  lastName: string = undefined;
  @IsNotEmpty()
  @IsEmail(undefined)
  email: string = undefined;
  isSuperuser = false;
  isStaff = false;
  isActive = false;
  @Transform(transformStringToDate, { toClassOnly: true })
  @Transform(transformDateToString, { toPlainOnly: true })
  lastLogin: Date = undefined;
  @Transform(transformStringToDate, { toClassOnly: true })
  @Transform(transformDateToString, { toPlainOnly: true })
  dateJoined: Date = undefined;
  @IsOptional()
  @Type(serializeModel(Group))
  groups: Group[] = [];
  @Transform(transformStringToDate, { toClassOnly: true })
  @Transform(transformDateToString, { toPlainOnly: true })
  dateOfBirth: Date = undefined;
github bradymholt / koa-vuejs-template / api / models / Validators.ts View on Github external
export function IsEmail(
  options?: IsEmailOptions,
  validationOptions?: ValidationOptions
) {
  return classValidator.IsEmail(
    options,
    Object.assign(
      {
        message: "must be a valid email address"
      },
      validationOptions
    )
  );
}
github JonJam / yorpw_ui_web / src / models / SiteViewModel.ts View on Github external
@IsNotEmpty({
    message: strings.siteViewModel.urlIsNotEmptyMessage
  })
  @IsUrl(undefined, {
    message: strings.siteViewModel.urlIsUrlMessage
  })
  @MaxLength(1000, {
    message: strings.siteViewModel.urlMaxLengthMessage
  })
  public readonly url: string;

  @IsNotEmpty({
    message: strings.siteViewModel.userNameIsNotEmptyMessage
  })
  @IsEmail(undefined, {
    message: strings.siteViewModel.userNameIsEmailMessage
  })
  @MaxLength(100, {
    message: strings.siteViewModel.userNameMaxLengthMessage
  })
  public readonly userName: string;

  @IsNotEmpty({
    message: strings.siteViewModel.passwordIsNotEmptyMessage
  })
  @MaxLength(100, {
    message: strings.siteViewModel.passwordMaxLengthMessage
  })
  public readonly password: string;

  @IsNotEmpty({
github goldcaddy77 / warthog / src / decorators / EmailField.ts View on Github external
export function EmailField(args: EmailFieldOptions = {}): any {
  const options = { unique: true, ...decoratorDefaults, ...args };

  const factories = [
    WarthogField('email', options),
    IsEmail(),
    Field(),
    Column(options) as MethodDecoratorFactory
  ];

  return composeMethodDecorators(...factories);
}
github rucken / core / libs / rucken / core / src / lib / modules / auth-modal / auth-modal.model.ts View on Github external
export class AuthModalModel implements IModel {
  static strings = {
    username: translate('Username'),
    email: translate('Email'),
    password: translate('Password'),
    rePassword: translate('Confirm password')
  };
  id: number = undefined;
  @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;
}
github EndyKaufman / ngx-dynamic-form-builder / apps / demo / src / app / shared / models / exp-user.ts View on Github external
import { ExpDepartment } from './exp-department';

export class ExpUser {
  id: number;

  @IsNotEmpty({
    groups: ['user', 'guest']
  })
  username: string;

  @IsNotEmpty({
    groups: ['guest']
  })
  password: string;

  @IsEmail(undefined, {
    groups: ['user']
  })
  @IsNotEmpty({
    groups: ['user']
  })
  email: string;

  isSuperuser: boolean;

  isStaff: boolean;

  @ValidateNested({
    groups: ['user']
  })
  @IsOptional({
    groups: ['user']