DEV Community

Discussion on: What was your win this week?

Collapse
 
shhdharmen profile image
Dharmen Shah

I created a lib for Angular...

GitHub logo ngneat / input-mask

🎭 @ngneat/input-mask is an angular library that creates an input mask

@ngneat/input-mask

npm (scoped) MIT commitizen PRs styled with prettier All Contributors ngneat-lib spectator semantic-release

@ngneat/input-mask is an angular library that creates an input mask. Behind the scene, it uses inputmask.

Features

  • 🔡 Support for form validation
  • 🎭 Wrapper function to easily create input-masks
  • 🔁 Helps you to convert final values to desired format
  • ☝️ Single directive to handle everything
  • 🛠 All the configurations of inputmask provided

Installation

You can install it through Angular CLI

ng add @ngneat/input-mask

or with npm

npm install @ngneat/input-mask inputmask@5
npm install -D @types/inputmask@5

When you install using npm or yarn, you will also need to import InputMaskModule in your app.module:

import { InputMaskModule } from '@ngneat/input-mask';

@NgModule({
  imports: [InputMaskModule],
})
class AppModule {}
Enter fullscreen mode Exit fullscreen mode

Usage examples

1. Date

import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { createMask } from '@ngneat/input-mask';
@Component({
  selector: 'app-root'
Enter fullscreen mode Exit fullscreen mode