0.0.5 • Published 1 year ago

gen-regex-angular v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

gen-regex-angular

Intro

Installation

npm i gen-regex-angular

Usage

Step 1

Import module in your app.component.ts file

import { GenRegexAngular } from 'gen-regex-angular';

Step 2

After import, create instance of imported module inside constructor

constructor(private genRegexAngular: GenRegexAngular) {}

Step 3

Now, you are all set to use this module in your angular project.

To use the particular regex pattern for formcontrol validation. Suppose we have to validate formcontrol "email". The code will look like

email = new FormControl('', [Validators.pattern(this.genRegexAngular.regexpattern('mail'))])

above code is similar to

email = new FormControl('', [Validators.pattern('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,10}$')])

Supported Parameters

You can find the parameters to use in function in below table.

ParameterUsageOutput
mailregexpattern('mail')^a-zA-Z0-9._%+-+@a-zA-Z0-9.-+.a-zA-Z{2,10}$
panregexpattern('pan')^a-zA-Z{5}0-9{4}a-zA-Z{1}$
aadharregexpattern('aadhar')^2-9{1}0-9{3}0-9{4}0-9{4}$
gstregexpattern('gst')^0-9{2}A-Z{5}0-9{4}A-Z{1}1-9A-Z{1}Z0-9A-Z{1}$

Currently, We focussed on these 4 primary patterns which are widely used in India. We are working on improving this module.