🚨 This repo has been moved to Justa Angular Library, see the projects folder to get the source code.
Some Angular Reactive Forms custom validators.
Main project to the Justa Reactive Forms custom validators. Go to projects folder to see the package.
run npm install --save @justa/ng-validators
Install the peerDependecies:
npm install --save moment @brazilian-utils/validators
Using the validators:
Import ReactiveFormsModule
in app.module.ts
Example with CNPJ Validator
import { Component } from "@angular/core";
import { FormGroup, FormControl } from "@angular/forms";
import { jstValidators } from "@justa/ng-validators";
@Component({
selector: "app",
template: require("./app.html")
})
export class AppComponent {
form: FormGroup;
constructor() {
this.form = new FormGroup({
field: new FormControl("", jstValidators.validateCNPJ)
});
}
}
Example on Stackblitz:
- validateDate (format: DD/MM/YYYY)
- validateCNPJ (format: xx.xxx.xxx/xxxx-xx | xxxxxxxxxxxxxx)
- validateCPF (format: xxx.xxx.xxx-xx | xxxxxxxxxxx)
- validatePhone (format: (xx)xxxxx-xxxx | (xx)xxxx-xxxx | xxxxxxxxxx)
- validateURL (format: http[s]://lol.com)
Run ng build @justa/validators
to build the project. The build artifacts will be stored in the dist/
directory.
To build the package, run ng build @justa/br-validators
.
MIT
Clone this repo, and install all dependencies. To build a new version, run this command:
ng build @justa/br-validators
.