You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ng16-rut

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng16-rut

Angular 16+ RUT =============

0.1.0
latest
npmnpm
Version published
Weekly downloads
5
Maintainers
0
Weekly downloads
 
Created
Source

Angular 16+ RUT

Angular 16+ library with several components to handle Chilean RUT validation, cleaning and formatting.

Installation

yarn add ng16-rut
# or
npm install ng16-rut --save

Usage

Set-up:

The easiest way to use this library is to import Ng16Rut in your app's main module.

import { NgModule } from '@angular/core';
import { Ng16Rut } from 'ng16-rut';
import { BrowserModule } from '@angular/platform-browser';

@NgModule({
  ...
  imports: [
    BrowserModule,
    Ng16Rut
  ],
})
class DemoAppModule { }

See ./demo folder for a fully working example.

Using it:

ng16-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 the validateRut directive (to attach to models or inputs) and the RutValidator class to be used as Validator on reactive forms.
  • RutPipe: Exposes the RutPipe pipe to format rut numbers on templates
  • RutDirective: Exposes the formatRut directive to format RUT inputs.

RutValidator

Reactive forms
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
export class DemoAppComponent {
  constructor (fb: FormBuilder, rutValidator: RutValidator) {
    this.reactiveForm = fb.group({
      rut: ['30972198', [Validators.required, rutValidator]]
    });
  }
}

Template Form
<input [(ngModel)]="user.rut" name="rut" validateRut required>

RutPipe

{{ user.rut }}
<!-- 30972198 -->
{{ user.rut | rut }}
<!-- 3.097.219-8 -->

formatRut (Directive)

<input [(ngModel)]="user.rut" name="rut" formatRut required>
<!--
(on blur)
3.097.219-8

(on focus)
30972198
-->

Contributing

  • 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

Credits

Thank you contributors!

Odisleysi

ng16-rut is maintained by odisleysi.

License

Angular 16+ RUT is © 2023 GDExpress, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.

FAQs

Package last updated on 21 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts