0.12.1 • Published 6 years ago

@ng-validators/ng-validators v0.12.1

Weekly downloads
33
License
MIT
Repository
github
Last release
6 years ago

npm version Build Status

Description

This repository contains native angular forms validators for both template driven and reactive forms.

Table of contents

Getting started

Install library

using npm

npm install @ng-validators/ng-validators --save 

using yarn

yarn add @ng-validators/ng-validators

Usage in reactive forms.

Import only validators you need for you form.

import { greaterThan } from '@ng-validators/ng-validators';

this.formBuilder.group({
    age: ['', greaterThan(18)]
});

Usage in template driven forms.

Import NgValidatorsModule @NgModule declarations.

import { NgValidatorsModule } from '@ng-validators/ng-validators';

@NgModule({
    imports: [NgValidatorsModule]
})
export class AppModule {
}

Now you can use validator directive in HTML template

<input class="form-control" type="text" ngModel name="gt" gt="10"/>

Validators

Angular built-in validators

  • required
  • minlength
  • maxlength
  • pattern

Custom validators

  • rangeLength
  • min
  • gt
  • gte
  • max
  • lt
  • lte
  • range
  • digits
  • number
  • url
  • email
  • date
  • minDate
  • maxDate
  • dateISO
  • creditCard
  • json
  • base64
  • uuid
  • equal
  • notEqual
  • equalTo
  • notEqualTo
  • Your validator can be here. PR is welcome :)

Contributing

Contributions are welcome. You can start by looking at issues with label Help wanted or creating new Issue with proposal or bug report. If you need validator but it is not listed here, you can submit PR with your validator.

License

MIT

0.12.1

6 years ago

0.11.0

6 years ago

0.10.4

6 years ago

0.10.3

6 years ago

0.10.1

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago