📝Validator Regexp

The module provides several methods to validate strings using regular expressions.

Imports

import { ValidatorRegexpService } from 'niro-health';

Method of Use

To use this module, you need to inject it into the desired service.

import { Module } from '@nestjs/common';
import {
  ValidatorRegexpService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IValidatorRegexpService',
      useClass: ValidatorRegexpService,
    },
  ],
})
export class AppModule {}

Injecting the module into our service.

import { Inject, Injectable } from '@nestjs/common';
import type { IValidatorRegexpService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IValidatorRegexpService')
    private readonly validatorRegexpService: IValidatorRegexpService,
  ) {}

  public dateISO(password: string) {
    return this.validatorRegexpService.date('2011-10-05T14:48:00.000Z').iso;
  }
}

Without dependencies

You won't need to connect the pieces with any other module.

Methods

Method
Scope
Description

_messageError

private

The method returns a message error.

_exec

private

The method executes the regular expression.

custom

public

The method executes the custom regular expression.

date

public

The regular expression for date.

string

public

The regular expression for string.

boolean

public

The regular expression for boolean.

number

public

The regular expression for number.

aws

public

The regular expression for aws.

node_env

public

The regular expression for node_env.

version

public

The regular expression for version.

uri

public

The regular expression for uri.

url

public

The regular expression for url.

postgresURL

public

The regular expression for url for PostgresSQL.

redisURL

public

The regular expression for url for Redis.

cronTimezone

public

The regular expression for cron timezone.

Last updated