Fork de https://github.com/platanus/ng2-rut para funcionar bajo Angular 9 debido a librerías deprecadas.
Angular 9 library with several components to handle Chilean RUT validation, cleaning and formatting.
yarn add ng9-rut
# or
npm install ng9-rut --save
The easiest way to use this library is to import Ng2Rut in your app's main module.
import { NgModule } from '@angular/core';
import { Ng9RutModule } from 'ng9-rut';
import { BrowserModule } from '@angular/platform-browser';
@NgModule({
...
imports: [
BrowserModule,
Ng9RutModule
],
})
class DemoAppModule { }
See ./demo
folder for a fully working example.
ng9-rut exposes multiple features that can be used to perform input validation and formatting. Probably you want to use one of the following:
RutValidator
: Exposes thevalidateRut
directive (to attach to models or inputs) and the RutValidator class to be used asValidator
on reactive forms.RutPipe
: Exposes theRutPipe
pipe to format rut numbers on templatesRutDirective
: Exposes theformatRut
directive to format RUT inputs.
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { RutValidator } from 'ng9-rut';
export class DemoAppComponent {
constructor (fb: FormBuilder, rutValidator: RutValidator) {
this.reactiveForm = fb.group({
rut: ['30972198', [Validators.required, rutValidator]]
});
}
}
<input [(ngModel)]="user.rut" name="rut" validateRut required>
{{ user.rut }}
<!-- 30972198 -->
{{ user.rut | rut }}
<!-- 3.097.219-8 -->
<input [(ngModel)]="user.rut" name="rut" formatRut required>
<!--
(on blur)
3.097.219-8
(on focus)
30972198
-->
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Esta lib fue actualizada en base al proyecto de los chicos de platanus. https://github.com/platanus/ng2-rut
Angular 2 RUT is © 2016 Platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.