Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcusviniciusss/angular-validate-br
Package for validations of the fields with angular.
https://github.com/marcusviniciusss/angular-validate-br
Last synced: 2 months ago
JSON representation
Package for validations of the fields with angular.
- Host: GitHub
- URL: https://github.com/marcusviniciusss/angular-validate-br
- Owner: MarcusViniciusSS
- Created: 2018-07-04T19:33:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-06T20:40:27.000Z (over 6 years ago)
- Last Synced: 2024-10-14T03:08:20.340Z (3 months ago)
- Language: TypeScript
- Size: 300 KB
- Stars: 8
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-validate-br
[![Build Status](https://img.shields.io/travis/erickants/angular-validate-br.svg)](https://travis-ci.org/fengyuanchen/cropperjs) [![Downloads](https://img.shields.io/npm/dw/angular-validate-br.svg)](https://www.npmjs.com/package/angular-validate-br) [![Version](https://img.shields.io/npm/v/angular-validate-br.svg)](https://www.npmjs.com/package/angular-validate-br)
> Library to projects on Angular to validate especific inputs with Brazilian rules.
> [Website](https://lowpoc.github.io/angular-validate-br/)
## Installation
```bash
npm install angular-validate-br --save
```### Basic usage
To use the benefits of the library simply import the dependency in your class or module to have the resources at your disposal.
* Reactive Forms
```typescript
//Reactive forms
import { ValidateBrService } from 'angular-validate-br';
@Component({
selector: 'lib-sample',
templateUrl: './sample.component.html',
styleUrls: ['./samle.component.css']
})
export class SampleComponent implements OnInit {
sampleForm: FormGroup;
constructor(private validateBrService: ValidateBrService) {
this.sampleForm = return new FormGroup({
personalData: new FormGroup({
money: new FormControl('', [this.validateBrService.decimal]),
cpf: new FormControl('', [this.validateBrService.cpf]),
cnpj: new FormControl('', [ this.validateBrService.cnpj])
}),
url: new FormControl('', [this.validateBrService.url]),
number: new FormControl('', this.validateBrService.integer)
});
}
```
* Template-driven forms```typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
import { SampleComponent } from './sample.component';
import { AngularValidateBrLibModule } from 'angular-validate-br';@NgModule({
declarations: [AppComponent, SampleComponent],
imports: [BrowserModule, FormsModule, AngularValidateBrLibModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
```
```html
Cpf is invalid
Cnpj is invalid
Url is invalid
```
## Bugs and features
Please, fell free to [open a new issue](https://github.com/Lowpoc/angular-validate-br/issues) on GitHub.
## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2018 Marcus Vinicius(@Lowpoc) & Erick Antunes(@erickants)