diff --git a/.editorconfig b/.editorconfig index f352616..6e87a00 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,10 +5,9 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [*.md] -max_line_length = 0 +max_line_length = off trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index c601905..711eb14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,41 @@ -.idea/ -typings/ -node_modules/ -dist/ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp +/out-tsc +/.ng_pkg_build + +# dependencies +/node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings + +# System Files .DS_Store -aot/ -!example/dist \ No newline at end of file +Thumbs.db +dist.tgz diff --git a/.npmignore b/.npmignore deleted file mode 100644 index b089d87..0000000 --- a/.npmignore +++ /dev/null @@ -1,15 +0,0 @@ -example/ -typings/ -.idea/ -.gitignore -index.html -tsconfig.json -typings.json -webpack.config.js -src/ -aot/ -.npmignore -karma-test-shim.js -karma.conf.js -CHANGELOG.md -rollup.config.js \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f2b2338..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - "4" - - "5" - - "6" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 42da133..dae2145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,36 @@ -# v3.4.0 - -add lt and gt validator - -# v3.5.0 - -re-trigger validate when validate-property change - -# v3.6.0 - -Improved US Phone Number formats -detail see https://github.com/yuyang041060120/ng2-validation/pull/43/ - -# v3.7.0 - -code split - -# v3.7.1 - -add umd file - -# v3.8.0 - -[#33](https://github.com/yuyang041060120/ng2-validation/issues/33) - -# v3.9.0 - -upgrade to angular 4 - -# v3.9.1 - -upgrade dev dependencies and webpack@2.x.x - -# v4.0.0 - -- support libphonenumber [#23](https://github.com/yuyang041060120/ng2-validation/issues/23) -- add lte and gte validator [#69](https://github.com/yuyang041060120/ng2-validation/issues/69) - -# v4.2.0 - -- add error details in range validator [#82](https://github.com/yuyang041060120/ng2-validation/issues/82) \ No newline at end of file +### [7.0.0] +- Angular 7 support +### [6.1.0] +- Merge pull request [#15](https://github.com/rsaenen/ngx-custom-validators/pull/15) +### [6.0.5] +- Fix issue [#11](https://github.com/rsaenen/ngx-custom-validators/issues/11) +### [6.0.4] +- Fix issue [#11](https://github.com/rsaenen/ngx-custom-validators/issues/11) +### [6.0.3] +- Modificiation of ArrayLength validator attribute (string -> number) +- Using ValidationErrors from @angular/forms to replace {[key: string]: any} +- Fix issue [#12](https://github.com/rsaenen/ngx-custom-validators/issues/12) +- Update dependencies +### [6.0.2] +- Fix issue with date/min-date/max-date validators with Moment.js and NgbDateStruct for months January and December +### [6.0.1] +- Date supports Moment.js +### [6.0.0] +- Angular 6 support +- Rename repository to ngx-custom-validators +### [5.1.0] +- Fix dependencies causing issues in some cases, dependencies should be devDependencies +- Remove `package-lock.json` see [angular-cli/angular-cli#7334](https://github.com/angular/angular-cli/issues/7334) +- Separated CHANGELOG created. +- ISSUE_TEMPLATE created. +### [5.0.3] +- Fix issue `ngModel` equals to null with `maxDate` and `minDate`. +### [5.0.2] +- fix for `max-date` and `min-date` validators +- ngModel type [ngbDateStruct](https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/datepicker/ngb-date-struct.ts) support for maxDate and minDate. +- Changelog initialization. +### [5.0.1] +- **Breaking change** Directive `email` renamed to `ngvemail` see [rsaenen/ngx-custom-validators#5](https://github.com/rsaenen/ngx-custom-validators/issues/5) +- Remove deprecated animations use for dev +### [5.0.0] +- Property validator with multiple properties check/Update dev dependencies (Angular 5) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..b1dd843 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,25 @@ +**IMPORTANT:** +_Please be specific with an example. An issue with_ + +**Steps to reproduce and a minimal demo** + + - _What steps should we try in your demo to see the problem?_ + - _Plunker example Appreciated_ + +**Current behavior** + + - + +**Expected/desired behavior** + + - + +**Environment information** + + - OS: + - Angular Version: + - Typescript version: + - npm version: + - Node Version: + +**Other information** diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7bc8add..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 YangYang Yu - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index b852d9d..6c681c3 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,72 @@ # Description -Angular2 custom validation, inspired by jQuery validation. +Angular Custom Validators, forked from [ng2-validation](https://github.com/yuyang041060120/ng2-validation). +Directives for form validation (template or model driven). -# Install +# Installation ```bash -npm install ng2-validation --save -``` -# Systemjs - -```bash -'ng2-validation': 'npm:ng2-validation/bundles/ng2-validation.umd.js' +npm i ngx-custom-validators --save ``` # Validators -## angular2 built-in validators +## Angular built-in validators -- required -- minlength - maxlength +- minlength - pattern +- required -## custom validators +## Custom validators -- rangeLength -- min -- gt -- gte -- max -- lt -- lte -- range +- array length +- base64 +- credit card +- date +- date ISO - digits -- number -- url - email -- date -- minDate -- maxDate -- dateISO -- creditCard +- equal +- not equal +- equal to +- not equal to +- greater than +- greater than or equal - json -- base64 -- phone +- less than +- less than or equal +- max +- max date +- min +- min date +- not equal +- not equal to +- number +- property +- range +- range length +- url - uuid -- equal -- notEqual -- equalTo -- notEqualTo # Usage -## template driven +The paramater of each validator (if it has) can be accessible in the template with `reason`. +```html + + +
error message and must be greater than {{ field.errors?.reason }}
+``` + +## Template driven import `FormsModule` and `CustomFormsModule` in *app.module.ts* -```javascript +```typescript import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { CustomFormsModule } from 'ng2-validation' +import { CustomFormsModule } from 'ngx-custom-validators'; import { AppComponent } from './app.component'; @@ -73,152 +79,153 @@ export class AppModule { } ``` -### rangeLength +### range length - rangeLength ```html - +error message
``` ### min ```html - +error message
``` -### gt +### greater than - gt ```html - +error message
``` -### gte +### greater than or equal - gte ```html - +error message
``` ### max ```html - +error message
``` -### lt +### less than - lt ```html - +error message
``` -### lte +### less than or equal - lte ```html - +error message
``` ### range ```html - +error message
``` ### digits ```html - +error message
``` ### number ```html - +error message
``` ### url ```html - +error message
``` ### email ```html - +error message
``` ### date ```html - +error message
``` -### minDate +### min date - minDate + +```html + +error message
+``` ```html - +error message
``` -### maxDate +### max date - maxDate ```html - +error message
``` -### dateISO +```html + +error message
+``` + +### date ISO - dateISO ```html - +error message
``` -### creditCard +### credit card - creditCard ```html - +error message
``` ### json ```html - +error message
``` ### base64 ```html - +error message
``` -### phone - -```html - -error message
-``` - -details see [libphonenumber](https://github.com/halt-hammerzeit/libphonenumber-js) - ### uuid ```html - +error message
``` @@ -234,40 +241,65 @@ details see [libphonenumber](https://github.com/halt-hammerzeit/libphonenumber-j ### equal ```html - +error message
``` -### equal +### not equal - notEqual ```html - +error message
``` -### equalTo +### equal to - equalTo ```html - +required error
- +equalTo error
``` -### notEqualTo +### not equal to - notEqualTo ```html - +required error
- +equalTo error
``` -## model driven +### property + +```typescript +public obj = { id: 1 } // OK +public obj = { name: 'baguette' } // KO +``` + +```html + + + +property error
+``` + +### array length - ArrayLength +```typescript +public arr = [{ name: 'baguette' }, { name: 'croisant' }] // OK +public arr = [{ name: 'baguette' }] // KO +``` + +```html + +arrayLength error
+``` + +## Model driven import `ReactiveFormsModule` in *app.module.ts* -```javascript +```typescript import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { ReactiveFormsModule } from '@angular/forms'; @@ -285,10 +317,10 @@ export class AppModule { import `CustomValidators` in *app.component.ts* -```javascript +```typescript import { Component } from '@angular/core'; import { FormGroup, FormControl } from '@angular/forms'; -import { CustomValidators } from 'ng2-validation'; +import { CustomValidators } from 'ngx-custom-validators'; @Component({ selector: 'app', @@ -306,139 +338,133 @@ export class AppComponent { ``` ```html - +error message
``` -### rangeLength +### range length - rangeLenght -```javascript +```typescript new FormControl('', CustomValidators.rangeLength([5, 9])) ``` ### min -```javascript +```typescript new FormControl('', CustomValidators.min(10)) ``` -### gt +### greater than - gt -```javascript +```typescript new FormControl('', CustomValidators.gt(10)) ``` ### max -```javascript +```typescript new FormControl('', CustomValidators.max(20)) ``` -### lt +### less than - lt -```javascript +```typescript new FormControl('', CustomValidators.lt(20)) ``` ### range -```javascript +```typescript new FormControl('', CustomValidators.range([10, 20])) ``` ### digits -```javascript +```typescript new FormControl('', CustomValidators.digits) ``` ### number -```javascript +```typescript new FormControl('', CustomValidators.number) ``` ### url -```javascript +```typescript new FormControl('', CustomValidators.url) ``` ### email -```javascript +```typescript new FormControl('', CustomValidators.email) ``` ### date -```javascript +```typescript new FormControl('', CustomValidators.date) ``` -### minDate +### min date - minDate -```javascript +```typescript new FormControl('', CustomValidators.minDate('2016-09-09')) ``` -### maxDate +### max date - maxDate -```javascript +```typescript new FormControl('', CustomValidators.maxDate('2016-09-09')) ``` -### dateISO +### date ISO - dateISO -```javascript +```typescript new FormControl('', CustomValidators.dateISO) ``` -### creditCard +### credit card - creditCard -```javascript +```typescript new FormControl('', CustomValidators.creditCard) ``` ### json -```javascript +```typescript new FormControl('', CustomValidators.json) ``` ### base64 -```javascript +```typescript new FormControl('', CustomValidators.base64) ``` -### phone - -```javascript -new FormControl('', CustomValidators.phone('zh-CN')) -``` - ### uuid -```javascript +```typescript new FormControl('', CustomValidators.uuid('3')) ``` ### equal -```javascript +```typescript new FormControl('', CustomValidators.equal('xxx')) ``` -### notEqual +### not equal - notEqual -```javascript +```typescript new FormControl('', CustomValidators.notEqual('xxx')) ``` -### equalTo +### equal to - equalTo -```javascript +```typescript let password = new FormControl('', Validators.required); let certainPassword = new FormControl('', CustomValidators.equalTo(password)); @@ -450,16 +476,16 @@ this.form = new FormGroup({ ```html ``` -### notEqualTo +### not equal to - notEqualTo -```javascript +```typescript let password = new FormControl('', Validators.required); let certainPassword = new FormControl('', CustomValidators.notEqualTo(password)); @@ -471,13 +497,46 @@ this.form = new FormGroup({ ```html ``` -# License +### property +```typescript +public obj = { id: 1 }; + +this.form = new FormGroup({ + obj: new FormControl('', CustomValidators.property('id')) + // For multiple properties check + obj: new FormControl('', CustomValidators.property('id,value,name')) +}); +``` + +```html + +``` + +### array length - ArrayLength +```typescript +public arr = [{ name: 'baguette' }, { name: 'croisant' }] +this.form = new FormGroup({ + arr: new FormControl('', CustomValidators.arrayLength(2)) +}); +``` + +```html + +``` -MIT +# For developpers +To run the projet : `npm start` +Don't forget to run `npm test` and `npm lint` before each pull request. Thanks ! diff --git a/angular.json b/angular.json new file mode 100644 index 0000000..1d95f8f --- /dev/null +++ b/angular.json @@ -0,0 +1,122 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "ngx-custom-validators": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/ngx-custom-validators", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "ngx-custom-validators:build" + }, + "configurations": { + "production": { + "browserTarget": "ngx-custom-validators:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "ngx-custom-validators:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.spec.json", + "karmaConfig": "src/karma.conf.js", + "styles": [ + "src/styles.css" + ], + "scripts": [], + "assets": [ + "src/favicon.ico", + "src/assets" + ] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "src/tsconfig.app.json", + "src/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } + }, + "ngx-custom-validators-e2e": { + "root": "e2e/", + "projectType": "application", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "ngx-custom-validators:serve" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": "e2e/tsconfig.e2e.json", + "exclude": [ + "**/node_modules/**" + ] + } + } + } + } + }, + "defaultProject": "ngx-custom-validators" +} \ No newline at end of file diff --git a/bundles/ng2-validation.umd.js b/bundles/ng2-validation.umd.js deleted file mode 100644 index 8ba702b..0000000 --- a/bundles/ng2-validation.umd.js +++ /dev/null @@ -1,1169 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('libphonenumber-js')) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/forms', 'libphonenumber-js'], factory) : - (factory((global.ng = global.ng || {}, global.ng.validation = global.ng.validation || {}),global.ng.core,global.ng.forms,global.libphonenumberJs)); -}(this, (function (exports,_angular_core,_angular_forms,libphonenumberJs) { 'use strict'; - -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - -function __metadata(k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -} - -var BASE64_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return Base64Validator$$1; }), - multi: true -}; -var Base64Validator$$1 = (function () { - function Base64Validator$$1() { - } - Base64Validator$$1.prototype.validate = function (c) { - return base64(c); - }; - return Base64Validator$$1; -}()); -Base64Validator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[base64][formControlName],[base64][formControl],[base64][ngModel]', - providers: [BASE64_VALIDATOR] - }) -], Base64Validator$$1); - -function isPresent(obj) { - return obj !== undefined && obj !== null; -} -function isDate(obj) { - return !/Invalid|NaN/.test(new Date(obj).toString()); -} - -var base64 = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return /^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i.test(v) ? null : { 'base64': true }; -}; - -var CREDIT_CARD_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return CreditCardValidator$$1; }), - multi: true -}; -var CreditCardValidator$$1 = (function () { - function CreditCardValidator$$1() { - } - CreditCardValidator$$1.prototype.validate = function (c) { - return creditCard(c); - }; - return CreditCardValidator$$1; -}()); -CreditCardValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[creditCard][formControlName],[creditCard][formControl],[creditCard][ngModel]', - providers: [CREDIT_CARD_VALIDATOR] - }) -], CreditCardValidator$$1); - -var creditCard = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - var sanitized = v.replace(/[^0-9]+/g, ''); - // problem with chrome - if (!(/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/.test(sanitized))) { - return { creditCard: true }; - } - var sum = 0; - var digit; - var tmpNum; - var shouldDouble; - for (var i = sanitized.length - 1; i >= 0; i--) { - digit = sanitized.substring(i, (i + 1)); - tmpNum = parseInt(digit, 10); - if (shouldDouble) { - tmpNum *= 2; - if (tmpNum >= 10) { - sum += ((tmpNum % 10) + 1); - } - else { - sum += tmpNum; - } - } - else { - sum += tmpNum; - } - shouldDouble = !shouldDouble; - } - if (Boolean((sum % 10) === 0 ? sanitized : false)) { - return null; - } - return { creditCard: true }; -}; - -var DATE_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return DateValidator$$1; }), - multi: true -}; -var DateValidator$$1 = (function () { - function DateValidator$$1() { - } - DateValidator$$1.prototype.validate = function (c) { - return date(c); - }; - return DateValidator$$1; -}()); -DateValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[date][formControlName],[date][formControl],[date][ngModel]', - providers: [DATE_VALIDATOR] - }) -], DateValidator$$1); - -var date = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return isDate(v) ? null : { date: true }; -}; - -var DATE_ISO_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return DateISOValidator$$1; }), - multi: true -}; -var DateISOValidator$$1 = (function () { - function DateISOValidator$$1() { - } - DateISOValidator$$1.prototype.validate = function (c) { - return dateISO(c); - }; - return DateISOValidator$$1; -}()); -DateISOValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[dateISO][formControlName],[dateISO][formControl],[dateISO][ngModel]', - providers: [DATE_ISO_VALIDATOR] - }) -], DateISOValidator$$1); - -var dateISO = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(v) ? null : { dateISO: true }; -}; - -var DIGITS_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return DigitsValidator$$1; }), - multi: true -}; -var DigitsValidator$$1 = (function () { - function DigitsValidator$$1() { - } - DigitsValidator$$1.prototype.validate = function (c) { - return digits(c); - }; - return DigitsValidator$$1; -}()); -DigitsValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[digits][formControlName],[digits][formControl],[digits][ngModel]', - providers: [DIGITS_VALIDATOR] - }) -], DigitsValidator$$1); - -var digits = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return /^\d+$/.test(v) ? null : { digits: true }; -}; - -var EMAIL_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return EmailValidator$$1; }), - multi: true -}; -var EmailValidator$$1 = (function () { - function EmailValidator$$1() { - } - EmailValidator$$1.prototype.validate = function (c) { - return email(c); - }; - return EmailValidator$$1; -}()); -EmailValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[email][formControlName],[email][formControl],[email][ngModel]', - providers: [EMAIL_VALIDATOR] - }) -], EmailValidator$$1); - -var email = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v) ? null : { 'email': true }; -}; - -var EQUAL_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return EqualValidator$$1; }), - multi: true -}; -var EqualValidator$$1 = (function () { - function EqualValidator$$1() { - } - EqualValidator$$1.prototype.ngOnInit = function () { - this.validator = equal(this.equal); - }; - EqualValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'equal') { - this.validator = equal(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - EqualValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - EqualValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return EqualValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Object) -], EqualValidator$$1.prototype, "equal", void 0); -EqualValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[equal][formControlName],[equal][formControl],[equal][ngModel]', - providers: [EQUAL_VALIDATOR] - }) -], EqualValidator$$1); - -var equal = function (val) { - return function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return val === v ? null : { equal: true }; - }; -}; - -var EQUAL_TO_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return EqualToValidator$$1; }), - multi: true -}; -var EqualToValidator$$1 = (function () { - function EqualToValidator$$1() { - } - EqualToValidator$$1.prototype.ngOnInit = function () { - this.validator = equalTo(this.equalTo); - }; - EqualToValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - return EqualToValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", typeof (_a = typeof _angular_forms.FormControl !== "undefined" && _angular_forms.FormControl) === "function" && _a || Object) -], EqualToValidator$$1.prototype, "equalTo", void 0); -EqualToValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[equalTo][formControlName],[equalTo][formControl],[equalTo][ngModel]', - providers: [EQUAL_TO_VALIDATOR] - }) -], EqualToValidator$$1); -var _a; - -var equalTo = function (equalControl) { - var subscribe = false; - return function (control) { - if (!subscribe) { - subscribe = true; - equalControl.valueChanges.subscribe(function () { - control.updateValueAndValidity(); - }); - } - var v = control.value; - return equalControl.value === v ? null : { equalTo: true }; - }; -}; - -var GREATER_THAN_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return GreaterThanValidator$$1; }), - multi: true -}; -var GreaterThanValidator$$1 = (function () { - function GreaterThanValidator$$1() { - } - GreaterThanValidator$$1.prototype.ngOnInit = function () { - this.validator = gt(this.gt); - }; - GreaterThanValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'gt') { - this.validator = gt(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - GreaterThanValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - GreaterThanValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return GreaterThanValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Number) -], GreaterThanValidator$$1.prototype, "gt", void 0); -GreaterThanValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[gt][formControlName],[gt][formControl],[gt][ngModel]', - providers: [GREATER_THAN_VALIDATOR] - }) -], GreaterThanValidator$$1); - -var gt = function (gt) { - return function (control) { - if (!isPresent(gt)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v > +gt ? null : { gt: true }; - }; -}; - -var GREATER_THAN_EQUAL_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return GreaterThanEqualValidator$$1; }), - multi: true -}; -var GreaterThanEqualValidator$$1 = (function () { - function GreaterThanEqualValidator$$1() { - } - GreaterThanEqualValidator$$1.prototype.ngOnInit = function () { - this.validator = gte(this.gte); - }; - GreaterThanEqualValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'gte') { - this.validator = gte(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - GreaterThanEqualValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - GreaterThanEqualValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return GreaterThanEqualValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Number) -], GreaterThanEqualValidator$$1.prototype, "gte", void 0); -GreaterThanEqualValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[gte][formControlName],[gte][formControl],[gte][ngModel]', - providers: [GREATER_THAN_EQUAL_VALIDATOR] - }) -], GreaterThanEqualValidator$$1); - -var gte = function (gte) { - return function (control) { - if (!isPresent(gte)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v >= +gte ? null : { gte: true }; - }; -}; - -var JSON_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return JSONValidator$$1; }), - multi: true -}; -var JSONValidator$$1 = (function () { - function JSONValidator$$1() { - } - JSONValidator$$1.prototype.validate = function (c) { - return json(c); - }; - return JSONValidator$$1; -}()); -JSONValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[json][formControlName],[json][formControl],[json][ngModel]', - providers: [JSON_VALIDATOR] - }) -], JSONValidator$$1); - -var json = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - try { - var obj = JSON.parse(v); - if (Boolean(obj) && typeof obj === 'object') { - return null; - } - } - catch (e) { - } - return { json: true }; -}; - -var LESS_THAN_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return LessThanValidator$$1; }), - multi: true -}; -var LessThanValidator$$1 = (function () { - function LessThanValidator$$1() { - } - LessThanValidator$$1.prototype.ngOnInit = function () { - this.validator = lt(this.lt); - }; - LessThanValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'lt') { - this.validator = lt(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - LessThanValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - LessThanValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return LessThanValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Number) -], LessThanValidator$$1.prototype, "lt", void 0); -LessThanValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[lt][formControlName],[lt][formControl],[lt][ngModel]', - providers: [LESS_THAN_VALIDATOR] - }) -], LessThanValidator$$1); - -var lt = function (lt) { - return function (control) { - if (!isPresent(lt)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v < +lt ? null : { lt: true }; - }; -}; - -var LESS_THAN_EQUAL_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return LessThanEqualValidator$$1; }), - multi: true -}; -var LessThanEqualValidator$$1 = (function () { - function LessThanEqualValidator$$1() { - } - LessThanEqualValidator$$1.prototype.ngOnInit = function () { - this.validator = lte(this.lte); - }; - LessThanEqualValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'lte') { - this.validator = lte(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - LessThanEqualValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - LessThanEqualValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return LessThanEqualValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Number) -], LessThanEqualValidator$$1.prototype, "lte", void 0); -LessThanEqualValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[lte][formControlName],[lte][formControl],[lte][ngModel]', - providers: [LESS_THAN_EQUAL_VALIDATOR] - }) -], LessThanEqualValidator$$1); - -var lte = function (lte) { - return function (control) { - if (!isPresent(lte)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v <= +lte ? null : { lte: true }; - }; -}; - -var MAX_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return MaxValidator$$1; }), - multi: true -}; -var MaxValidator$$1 = (function () { - function MaxValidator$$1() { - } - MaxValidator$$1.prototype.ngOnInit = function () { - this.validator = max(this.max); - }; - MaxValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'max') { - this.validator = max(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - MaxValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - MaxValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return MaxValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Number) -], MaxValidator$$1.prototype, "max", void 0); -MaxValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[max][formControlName],[max][formControl],[max][ngModel]', - providers: [MAX_VALIDATOR] - }) -], MaxValidator$$1); - -var max = function (max) { - return function (control) { - if (!isPresent(max)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v <= +max ? null : { actualValue: v, requiredValue: +max, max: true }; - }; -}; - -var MAX_DATE_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return MaxDateValidator$$1; }), - multi: true -}; -var MaxDateValidator$$1 = (function () { - function MaxDateValidator$$1() { - } - MaxDateValidator$$1.prototype.ngOnInit = function () { - this.validator = maxDate(this.maxDate); - }; - MaxDateValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'maxDate') { - this.validator = maxDate(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - MaxDateValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - MaxDateValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return MaxDateValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Object) -], MaxDateValidator$$1.prototype, "maxDate", void 0); -MaxDateValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[maxDate][formControlName],[maxDate][formControl],[maxDate][ngModel]', - providers: [MAX_DATE_VALIDATOR] - }) -], MaxDateValidator$$1); - -var maxDate = function (maxDate) { - if (!isDate(maxDate) && !(maxDate instanceof Function)) { - throw Error('maxDate value must be or return a formatted date'); - } - return function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var d = new Date(control.value); - if (!isDate(d)) - return { maxDate: true }; - if (maxDate instanceof Function) - maxDate = maxDate(); - return d <= new Date(maxDate) ? null : { maxDate: true }; - }; -}; - -var MIN_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return MinValidator$$1; }), - multi: true -}; -var MinValidator$$1 = (function () { - function MinValidator$$1() { - } - MinValidator$$1.prototype.ngOnInit = function () { - this.validator = min(this.min); - }; - MinValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'min') { - this.validator = min(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - MinValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - MinValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return MinValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Number) -], MinValidator$$1.prototype, "min", void 0); -MinValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[min][formControlName],[min][formControl],[min][ngModel]', - providers: [MIN_VALIDATOR] - }) -], MinValidator$$1); - -var min = function (min) { - return function (control) { - if (!isPresent(min)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v >= +min ? null : { actualValue: v, requiredValue: +min, min: true }; - }; -}; - -var MIN_DATE_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return MinDateValidator$$1; }), - multi: true -}; -var MinDateValidator$$1 = (function () { - function MinDateValidator$$1() { - } - MinDateValidator$$1.prototype.ngOnInit = function () { - this.validator = minDate(this.minDate); - }; - MinDateValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'minDate') { - this.validator = minDate(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - MinDateValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - MinDateValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return MinDateValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Object) -], MinDateValidator$$1.prototype, "minDate", void 0); -MinDateValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[minDate][formControlName],[minDate][formControl],[minDate][ngModel]', - providers: [MIN_DATE_VALIDATOR] - }) -], MinDateValidator$$1); - -var minDate = function (minDate) { - if (!isDate(minDate) && !(minDate instanceof Function)) { - throw Error('minDate value must be or return a formatted date'); - } - return function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var d = new Date(control.value); - if (!isDate(d)) - return { minDate: true }; - if (minDate instanceof Function) - minDate = minDate(); - return d >= new Date(minDate) ? null : { minDate: true }; - }; -}; - -var NOT_EQUAL_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return NotEqualValidator$$1; }), - multi: true -}; -var NotEqualValidator$$1 = (function () { - function NotEqualValidator$$1() { - } - NotEqualValidator$$1.prototype.ngOnInit = function () { - this.validator = notEqual(this.notEqual); - }; - NotEqualValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'notEqual') { - this.validator = notEqual(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - NotEqualValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - NotEqualValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return NotEqualValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Object) -], NotEqualValidator$$1.prototype, "notEqual", void 0); -NotEqualValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[notEqual][formControlName],[notEqual][formControl],[notEqual][ngModel]', - providers: [NOT_EQUAL_VALIDATOR] - }) -], NotEqualValidator$$1); - -var notEqual = function (val) { - return function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return val !== v ? null : { notEqual: true }; - }; -}; - -var NOT_EQUAL_TO_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return NotEqualToValidator$$1; }), - multi: true -}; -var NotEqualToValidator$$1 = (function () { - function NotEqualToValidator$$1() { - } - NotEqualToValidator$$1.prototype.ngOnInit = function () { - this.validator = notEqualTo(this.notEqualTo); - }; - NotEqualToValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - return NotEqualToValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", typeof (_a$1 = typeof _angular_forms.FormControl !== "undefined" && _angular_forms.FormControl) === "function" && _a$1 || Object) -], NotEqualToValidator$$1.prototype, "notEqualTo", void 0); -NotEqualToValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[notEqualTo][formControlName],[notEqualTo][formControl],[notEqualTo][ngModel]', - providers: [NOT_EQUAL_TO_VALIDATOR] - }) -], NotEqualToValidator$$1); -var _a$1; - -var notEqualTo = function (notEqualControl) { - var subscribe = false; - return function (control) { - if (!subscribe) { - subscribe = true; - notEqualControl.valueChanges.subscribe(function () { - control.updateValueAndValidity(); - }); - } - var v = control.value; - return notEqualControl.value !== v ? null : { notEqualTo: true }; - }; -}; - -var NUMBER_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return NumberValidator$$1; }), - multi: true -}; -var NumberValidator$$1 = (function () { - function NumberValidator$$1() { - } - NumberValidator$$1.prototype.validate = function (c) { - return number(c); - }; - return NumberValidator$$1; -}()); -NumberValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[number][formControlName],[number][formControl],[number][ngModel]', - providers: [NUMBER_VALIDATOR] - }) -], NumberValidator$$1); - -var number = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(v) ? null : { 'number': true }; -}; - -var PHONE_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return PhoneValidator$$1; }), - multi: true -}; -var PhoneValidator$$1 = (function () { - function PhoneValidator$$1() { - } - PhoneValidator$$1.prototype.ngOnInit = function () { - this.validator = phone(this.phone); - }; - PhoneValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'phone') { - this.validator = phone(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - PhoneValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - PhoneValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return PhoneValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", String) -], PhoneValidator$$1.prototype, "phone", void 0); -PhoneValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[phone][formControlName],[phone][formControl],[phone][ngModel]', - providers: [PHONE_VALIDATOR] - }) -], PhoneValidator$$1); - -var phone = function (country) { - return function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return libphonenumberJs.isValidNumber({ phone: v, country: country }) ? null : { phone: true }; - }; -}; - -var RANGE_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return RangeValidator$$1; }), - multi: true -}; -var RangeValidator$$1 = (function () { - function RangeValidator$$1() { - } - RangeValidator$$1.prototype.ngOnInit = function () { - this.validator = range(this.range); - }; - RangeValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'range') { - this.validator = range(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - RangeValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - RangeValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return RangeValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Array) -], RangeValidator$$1.prototype, "range", void 0); -RangeValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[range][formControlName],[range][formControl],[range][ngModel]', - providers: [RANGE_VALIDATOR] - }) -], RangeValidator$$1); - -var range = function (range) { - return function (control) { - if (!isPresent(range)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = +control.value; - return v >= range[0] && v <= range[1] ? null : { actualValue: v, requiredValue: range, range: true }; - }; -}; - -var RANGE_LENGTH_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return RangeLengthValidator$$1; }), - multi: true -}; -var RangeLengthValidator$$1 = (function () { - function RangeLengthValidator$$1() { - } - RangeLengthValidator$$1.prototype.ngOnInit = function () { - this.validator = rangeLength(this.rangeLength); - }; - RangeLengthValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'rangeLength') { - this.validator = rangeLength(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - RangeLengthValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - RangeLengthValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return RangeLengthValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Array) -], RangeLengthValidator$$1.prototype, "rangeLength", void 0); -RangeLengthValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[rangeLength][formControlName],[rangeLength][formControl],[rangeLength][ngModel]', - providers: [RANGE_LENGTH_VALIDATOR] - }) -], RangeLengthValidator$$1); - -var rangeLength = function (rangeLength) { - return function (control) { - if (!isPresent(rangeLength)) - return null; - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return v.length >= rangeLength[0] && v.length <= rangeLength[1] ? null : { rangeLength: true }; - }; -}; - -var URL_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return UrlValidator$$1; }), - multi: true -}; -var UrlValidator$$1 = (function () { - function UrlValidator$$1() { - } - UrlValidator$$1.prototype.validate = function (c) { - return url(c); - }; - return UrlValidator$$1; -}()); -UrlValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[url][formControlName],[url][formControl],[url][ngModel]', - providers: [URL_VALIDATOR] - }) -], UrlValidator$$1); - -var url = function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(v) ? null : { 'url': true }; -}; - -var UUID_VALIDATOR = { - provide: _angular_forms.NG_VALIDATORS, - useExisting: _angular_core.forwardRef(function () { return UUIDValidator$$1; }), - multi: true -}; -var UUIDValidator$$1 = (function () { - function UUIDValidator$$1() { - } - UUIDValidator$$1.prototype.ngOnInit = function () { - this.validator = uuid(this.uuid); - }; - UUIDValidator$$1.prototype.ngOnChanges = function (changes) { - for (var key in changes) { - if (key === 'uuid') { - this.validator = uuid(changes[key].currentValue); - if (this.onChange) - this.onChange(); - } - } - }; - UUIDValidator$$1.prototype.validate = function (c) { - return this.validator(c); - }; - UUIDValidator$$1.prototype.registerOnValidatorChange = function (fn) { - this.onChange = fn; - }; - return UUIDValidator$$1; -}()); -__decorate([ - _angular_core.Input(), - __metadata("design:type", Object) -], UUIDValidator$$1.prototype, "uuid", void 0); -UUIDValidator$$1 = __decorate([ - _angular_core.Directive({ - selector: '[uuid][formControlName],[uuid][formControl],[uuid][ngModel]', - providers: [UUID_VALIDATOR] - }) -], UUIDValidator$$1); - -var uuids = { - '3': /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, - '4': /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, - '5': /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, - 'all': /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i -}; -var uuid = function (version) { - return function (control) { - if (isPresent(_angular_forms.Validators.required(control))) - return null; - var v = control.value; - var pattern = uuids[version] || uuids.all; - return (new RegExp(pattern)).test(v) ? null : { uuid: true }; - }; -}; - -var CustomValidators = { - base64: base64, - creditCard: creditCard, - date: date, - dateISO: dateISO, - digits: digits, - email: email, - equal: equal, - equalTo: equalTo, - gt: gt, - gte: gte, - json: json, - lt: lt, - lte: lte, - max: max, - maxDate: maxDate, - min: min, - minDate: minDate, - notEqual: notEqual, - notEqualTo: notEqualTo, - number: number, - phone: phone, - range: range, - rangeLength: rangeLength, - url: url, - uuid: uuid -}; -var CUSTOM_FORM_DIRECTIVES = [ - Base64Validator$$1, - CreditCardValidator$$1, - DateValidator$$1, - DateISOValidator$$1, - DigitsValidator$$1, - EmailValidator$$1, - EqualValidator$$1, - EqualToValidator$$1, - GreaterThanValidator$$1, - GreaterThanEqualValidator$$1, - JSONValidator$$1, - LessThanValidator$$1, - LessThanEqualValidator$$1, - MaxValidator$$1, - MaxDateValidator$$1, - MinValidator$$1, - MinDateValidator$$1, - NotEqualValidator$$1, - NotEqualToValidator$$1, - NumberValidator$$1, - PhoneValidator$$1, - RangeValidator$$1, - RangeLengthValidator$$1, - UrlValidator$$1, - UUIDValidator$$1 -]; -exports.CustomFormsModule = (function () { - function CustomFormsModule() { - } - return CustomFormsModule; -}()); -exports.CustomFormsModule = __decorate([ - _angular_core.NgModule({ - declarations: [CUSTOM_FORM_DIRECTIVES], - exports: [CUSTOM_FORM_DIRECTIVES] - }) -], exports.CustomFormsModule); - -exports.CustomValidators = CustomValidators; - -Object.defineProperty(exports, '__esModule', { value: true }); - -}))); -//# sourceMappingURL=ng2-validation.umd.js.map diff --git a/bundles/ng2-validation.umd.js.map b/bundles/ng2-validation.umd.js.map deleted file mode 100644 index 15713a8..0000000 --- a/bundles/ng2-validation.umd.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ng2-validation.umd.js","sources":["../src/base64/directive.ts","../src/util/lang.ts","../src/base64/validator.ts","../src/credit-card/directive.ts","../src/credit-card/validator.ts","../src/date/directive.ts","../src/date/validator.ts","../src/date-ios/directive.ts","../src/date-ios/validator.ts","../src/digits/directive.ts","../src/digits/validator.ts","../src/email/directive.ts","../src/email/validator.ts","../src/equal/directive.ts","../src/equal/validator.ts","../src/equal-to/directive.ts","../src/equal-to/validator.ts","../src/greater-than/directive.ts","../src/greater-than/validator.ts","../src/greater-than-equal/directive.ts","../src/greater-than-equal/validator.ts","../src/json/directive.ts","../src/json/validator.ts","../src/less-than/directive.ts","../src/less-than/validator.ts","../src/less-than-equal/directive.ts","../src/less-than-equal/validator.ts","../src/max/directive.ts","../src/max/validator.ts","../src/max-date/directive.ts","../src/max-date/validator.ts","../src/min/directive.ts","../src/min/validator.ts","../src/min-date/directive.ts","../src/min-date/validator.ts","../src/not-equal/directive.ts","../src/not-equal/validator.ts","../src/not-equal-to/directive.ts","../src/not-equal-to/validator.ts","../src/number/directive.ts","../src/number/validator.ts","../src/phone/directive.ts","../src/phone/validator.ts","../src/range/directive.ts","../src/range/validator.ts","../src/range-length/directive.ts","../src/range-length/validator.ts","../src/url/directive.ts","../src/url/validator.ts","../src/uuid/directive.ts","../src/uuid/validator.ts","../src/index.ts"],"sourcesContent":["import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { base64 } from './';\n\nconst BASE64_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => Base64Validator),\n multi: true\n};\n\n@Directive({\n selector: '[base64][formControlName],[base64][formControl],[base64][ngModel]',\n providers: [BASE64_VALIDATOR]\n})\nexport class Base64Validator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return base64(c);\n }\n}\n","export function isPresent(obj: any): boolean {\n return obj !== undefined && obj !== null;\n}\n\nexport function isDate(obj: any): boolean {\n return !/Invalid|NaN/.test(new Date(obj).toString());\n}","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const base64: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n return /^(?:[A-Z0-9+\\/]{4})*(?:[A-Z0-9+\\/]{2}==|[A-Z0-9+\\/]{3}=|[A-Z0-9+\\/]{4})$/i.test(v) ? null : {'base64': true};\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { creditCard } from './';\n\nconst CREDIT_CARD_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => CreditCardValidator),\n multi: true\n};\n\n@Directive({\n selector: '[creditCard][formControlName],[creditCard][formControl],[creditCard][ngModel]',\n providers: [CREDIT_CARD_VALIDATOR]\n})\nexport class CreditCardValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return creditCard(c);\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const creditCard: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n\n let sanitized = v.replace(/[^0-9]+/g, '');\n\n // problem with chrome\n if (!(/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11})$/.test(sanitized))) {\n return {creditCard: true};\n }\n\n let sum = 0;\n let digit;\n let tmpNum;\n let shouldDouble;\n for (let i = sanitized.length - 1; i >= 0; i--) {\n digit = sanitized.substring(i, (i + 1));\n tmpNum = parseInt(digit, 10);\n if (shouldDouble) {\n tmpNum *= 2;\n if (tmpNum >= 10) {\n sum += ((tmpNum % 10) + 1);\n } else {\n sum += tmpNum;\n }\n } else {\n sum += tmpNum;\n }\n shouldDouble = !shouldDouble;\n }\n\n if (Boolean((sum % 10) === 0 ? sanitized : false)) {\n return null;\n }\n\n return {creditCard: true};\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { date } from './';\n\nconst DATE_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => DateValidator),\n multi: true\n};\n\n@Directive({\n selector: '[date][formControlName],[date][formControl],[date][ngModel]',\n providers: [DATE_VALIDATOR]\n})\nexport class DateValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return date(c);\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent, isDate } from '../util/lang';\n\nexport const date: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n return isDate(v) ? null : {date: true};\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { dateISO } from './';\n\nconst DATE_ISO_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => DateISOValidator),\n multi: true\n};\n\n@Directive({\n selector: '[dateISO][formControlName],[dateISO][formControl],[dateISO][ngModel]',\n providers: [DATE_ISO_VALIDATOR]\n})\nexport class DateISOValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return dateISO(c);\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent, isDate } from '../util/lang';\n\nexport const dateISO: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n return /^\\d{4}[\\/\\-](0?[1-9]|1[012])[\\/\\-](0?[1-9]|[12][0-9]|3[01])$/.test(v) ? null : {dateISO: true};\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { digits } from './';\n\nconst DIGITS_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => DigitsValidator),\n multi: true\n};\n\n@Directive({\n selector: '[digits][formControlName],[digits][formControl],[digits][ngModel]',\n providers: [DIGITS_VALIDATOR]\n})\nexport class DigitsValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return digits(c);\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const digits: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n return /^\\d+$/.test(v) ? null : {digits: true};\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { email } from './index';\n\nconst EMAIL_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => EmailValidator),\n multi: true\n};\n\n@Directive({\n selector: '[email][formControlName],[email][formControl],[email][ngModel]',\n providers: [EMAIL_VALIDATOR]\n})\nexport class EmailValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return email(c);\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const email: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n return /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/.test(v) ? null : {'email': true};\n};\n","import { Directive, Input, forwardRef, OnInit, SimpleChanges, OnChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { equal } from './index';\n\nconst EQUAL_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => EqualValidator),\n multi: true\n};\n\n@Directive({\n selector: '[equal][formControlName],[equal][formControl],[equal][ngModel]',\n providers: [EQUAL_VALIDATOR]\n})\nexport class EqualValidator implements Validator, OnInit, OnChanges {\n @Input() equal: any;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = equal(this.equal);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'equal') {\n this.validator = equal(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const equal = (val: any): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: any} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: any = control.value;\n\n return val === v ? null : {equal: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit } from '@angular/core';\nimport { NG_VALIDATORS, Validator, FormControl, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { equalTo } from './';\n\nconst EQUAL_TO_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => EqualToValidator),\n multi: true\n};\n\n@Directive({\n selector: '[equalTo][formControlName],[equalTo][formControl],[equalTo][ngModel]',\n providers: [EQUAL_TO_VALIDATOR]\n})\nexport class EqualToValidator implements Validator, OnInit {\n @Input() equalTo: FormControl;\n\n private validator: ValidatorFn;\n\n ngOnInit() {\n this.validator = equalTo(this.equalTo);\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n}","import { AbstractControl, ValidatorFn } from '@angular/forms';\n\nexport const equalTo = (equalControl: AbstractControl): ValidatorFn => {\n let subscribe: boolean = false;\n\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (!subscribe) {\n subscribe = true;\n equalControl.valueChanges.subscribe(() => {\n control.updateValueAndValidity();\n });\n }\n\n let v: string = control.value;\n\n return equalControl.value === v ? null : {equalTo: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { gt } from './';\n\nconst GREATER_THAN_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => GreaterThanValidator),\n multi: true\n};\n\n@Directive({\n selector: '[gt][formControlName],[gt][formControl],[gt][ngModel]',\n providers: [GREATER_THAN_VALIDATOR]\n})\nexport class GreaterThanValidator implements Validator, OnInit, OnChanges {\n @Input() gt: number;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = gt(this.gt);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'gt') {\n this.validator = gt(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const gt = (gt: number): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (!isPresent(gt)) return null;\n if (isPresent(Validators.required(control))) return null;\n\n let v: number = +control.value;\n return v > +gt ? null : {gt: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { gte } from './';\n\nconst GREATER_THAN_EQUAL_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => GreaterThanEqualValidator),\n multi: true\n};\n\n@Directive({\n selector: '[gte][formControlName],[gte][formControl],[gte][ngModel]',\n providers: [GREATER_THAN_EQUAL_VALIDATOR]\n})\nexport class GreaterThanEqualValidator implements Validator, OnInit, OnChanges {\n @Input() gte: number;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = gte(this.gte);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'gte') {\n this.validator = gte(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const gte = (gte: number): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (!isPresent(gte)) return null;\n if (isPresent(Validators.required(control))) return null;\n\n let v: number = +control.value;\n return v >= +gte ? null : {gte: true};\n };\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { json } from './';\n\nconst JSON_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => JSONValidator),\n multi: true\n};\n\n@Directive({\n selector: '[json][formControlName],[json][formControl],[json][ngModel]',\n providers: [JSON_VALIDATOR]\n})\nexport class JSONValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return json(c);\n }\n}","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const json: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n\n try {\n let obj = JSON.parse(v);\n\n if (Boolean(obj) && typeof obj === 'object') {\n return null;\n }\n } catch (e) {\n }\n return {json: true};\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { lt } from './';\n\nconst LESS_THAN_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => LessThanValidator),\n multi: true\n};\n\n@Directive({\n selector: '[lt][formControlName],[lt][formControl],[lt][ngModel]',\n providers: [LESS_THAN_VALIDATOR]\n})\nexport class LessThanValidator implements Validator, OnInit, OnChanges {\n @Input() lt: number;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = lt(this.lt);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'lt') {\n this.validator = lt(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const lt = (lt: number): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (!isPresent(lt)) return null;\n if (isPresent(Validators.required(control))) return null;\n\n let v: number = +control.value;\n return v < +lt ? null : {lt: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { lte } from './';\n\nconst LESS_THAN_EQUAL_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => LessThanEqualValidator),\n multi: true\n};\n\n@Directive({\n selector: '[lte][formControlName],[lte][formControl],[lte][ngModel]',\n providers: [LESS_THAN_EQUAL_VALIDATOR]\n})\nexport class LessThanEqualValidator implements Validator, OnInit, OnChanges {\n @Input() lte: number;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = lte(this.lte);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'lte') {\n this.validator = lte(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const lte = (lte: number): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (!isPresent(lte)) return null;\n if (isPresent(Validators.required(control))) return null;\n\n let v: number = +control.value;\n return v <= +lte ? null : {lte: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { max } from './';\n\nconst MAX_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => MaxValidator),\n multi: true\n};\n\n@Directive({\n selector: '[max][formControlName],[max][formControl],[max][ngModel]',\n providers: [MAX_VALIDATOR]\n})\nexport class MaxValidator implements Validator, OnInit, OnChanges {\n @Input() max: number;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = max(this.max);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'max') {\n this.validator = max(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const max = (max: number): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: any} => {\n if (!isPresent(max)) return null;\n if (isPresent(Validators.required(control))) return null;\n\n let v: number = +control.value;\n return v <= +max ? null : {actualValue: v, requiredValue: +max, max: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { maxDate } from './';\n\nconst MAX_DATE_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => MaxDateValidator),\n multi: true\n};\n\n@Directive({\n selector: '[maxDate][formControlName],[maxDate][formControl],[maxDate][ngModel]',\n providers: [MAX_DATE_VALIDATOR]\n})\nexport class MaxDateValidator implements Validator, OnInit, OnChanges {\n @Input() maxDate;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = maxDate(this.maxDate);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'maxDate') {\n this.validator = maxDate(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent, isDate } from '../util/lang';\n\nexport const maxDate = (maxDate: any): ValidatorFn => {\n if (!isDate(maxDate) && !(maxDate instanceof Function)) {\n throw Error('maxDate value must be or return a formatted date');\n }\n\n return (control: AbstractControl): {[key: string]: any} => {\n if (isPresent(Validators.required(control))) return null;\n\n let d: Date = new Date(control.value);\n\n if (!isDate(d)) return {maxDate: true};\n if (maxDate instanceof Function) maxDate = maxDate();\n\n return d <= new Date(maxDate) ? null : {maxDate: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { min } from './';\n\nconst MIN_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => MinValidator),\n multi: true\n};\n\n@Directive({\n selector: '[min][formControlName],[min][formControl],[min][ngModel]',\n providers: [MIN_VALIDATOR]\n})\nexport class MinValidator implements Validator, OnInit, OnChanges {\n @Input() min: number;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = min(this.min);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'min') {\n this.validator = min(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const min = (min: number): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: any} => {\n if (!isPresent(min)) return null;\n if (isPresent(Validators.required(control))) return null;\n\n let v: number = +control.value;\n return v >= +min ? null : {actualValue: v, requiredValue: +min, min: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { minDate } from './';\n\nconst MIN_DATE_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => MinDateValidator),\n multi: true\n};\n\n@Directive({\n selector: '[minDate][formControlName],[minDate][formControl],[minDate][ngModel]',\n providers: [MIN_DATE_VALIDATOR]\n})\nexport class MinDateValidator implements Validator, OnInit, OnChanges {\n @Input() minDate;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = minDate(this.minDate);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'minDate') {\n this.validator = minDate(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent, isDate } from '../util/lang';\n\nexport const minDate = (minDate: any): ValidatorFn => {\n\n if (!isDate(minDate) && !(minDate instanceof Function)) {\n throw Error('minDate value must be or return a formatted date');\n }\n\n return (control: AbstractControl): {[key: string]: any} => {\n if (isPresent(Validators.required(control))) return null;\n\n let d: Date = new Date(control.value);\n\n if (!isDate(d)) return {minDate: true};\n if (minDate instanceof Function) minDate = minDate();\n\n return d >= new Date(minDate) ? null : {minDate: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, SimpleChanges, OnChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { notEqual } from './index';\n\nconst NOT_EQUAL_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => NotEqualValidator),\n multi: true\n};\n\n@Directive({\n selector: '[notEqual][formControlName],[notEqual][formControl],[notEqual][ngModel]',\n providers: [NOT_EQUAL_VALIDATOR]\n})\nexport class NotEqualValidator implements Validator, OnInit, OnChanges {\n @Input() notEqual: any;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = notEqual(this.notEqual);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'notEqual') {\n this.validator = notEqual(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const notEqual = (val: any): ValidatorFn => {\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: any = control.value;\n\n return val !== v ? null : {notEqual: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit } from '@angular/core';\nimport { NG_VALIDATORS, Validator, FormControl, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { notEqualTo } from './';\n\nconst NOT_EQUAL_TO_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => NotEqualToValidator),\n multi: true\n};\n\n@Directive({\n selector: '[notEqualTo][formControlName],[notEqualTo][formControl],[notEqualTo][ngModel]',\n providers: [NOT_EQUAL_TO_VALIDATOR]\n})\nexport class NotEqualToValidator implements Validator, OnInit {\n @Input() notEqualTo: FormControl;\n\n private validator: ValidatorFn;\n\n ngOnInit() {\n this.validator = notEqualTo(this.notEqualTo);\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n}\n","import { AbstractControl, ValidatorFn } from '@angular/forms';\n\nexport const notEqualTo = (notEqualControl: AbstractControl): ValidatorFn => {\n let subscribe: boolean = false;\n return (control: AbstractControl): {[key: string]: boolean} => {\n if (!subscribe) {\n subscribe = true;\n notEqualControl.valueChanges.subscribe(() => {\n control.updateValueAndValidity();\n });\n }\n\n let v: string = control.value;\n\n return notEqualControl.value !== v ? null : {notEqualTo: true};\n };\n};\n","import { Directive, forwardRef } from '@angular/core';\nimport { NG_VALIDATORS, Validator, AbstractControl } from '@angular/forms';\n\nimport { number } from './';\n\nconst NUMBER_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => NumberValidator),\n multi: true\n};\n\n@Directive({\n selector: '[number][formControlName],[number][formControl],[number][ngModel]',\n providers: [NUMBER_VALIDATOR]\n})\nexport class NumberValidator implements Validator {\n validate(c: AbstractControl): {[key: string]: any} {\n return number(c);\n }\n}","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const number: ValidatorFn = (control: AbstractControl): {[key: string]: boolean} => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n return /^(?:-?\\d+|-?\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$/.test(v) ? null : {'number': true};\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { phone } from './';\n\nconst PHONE_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => PhoneValidator),\n multi: true\n};\n\n@Directive({\n selector: '[phone][formControlName],[phone][formControl],[phone][ngModel]',\n providers: [PHONE_VALIDATOR]\n})\nexport class PhoneValidator implements Validator, OnInit, OnChanges {\n @Input() phone: string;\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = phone(this.phone);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'phone') {\n this.validator = phone(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\nimport { isValidNumber } from 'libphonenumber-js';\n\nimport { isPresent } from '../util/lang';\n\nexport const phone = (country: string): ValidatorFn => {\n return (control: AbstractControl): { [key: string]: boolean } => {\n if (isPresent(Validators.required(control))) return null;\n\n let v: string = control.value;\n\n return isValidNumber({phone: v, country}) ? null : {phone: true};\n };\n};\n","import { Directive, Input, forwardRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';\nimport { NG_VALIDATORS, Validator, ValidatorFn, AbstractControl } from '@angular/forms';\n\nimport { range } from './';\n\nconst RANGE_VALIDATOR: any = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => RangeValidator),\n multi: true\n};\n\n@Directive({\n selector: '[range][formControlName],[range][formControl],[range][ngModel]',\n providers: [RANGE_VALIDATOR]\n})\nexport class RangeValidator implements Validator, OnInit, OnChanges {\n @Input() range: [number];\n\n private validator: ValidatorFn;\n private onChange: () => void;\n\n ngOnInit() {\n this.validator = range(this.range);\n }\n\n ngOnChanges(changes: SimpleChanges) {\n for (let key in changes) {\n if (key === 'range') {\n this.validator = range(changes[key].currentValue);\n if (this.onChange) this.onChange();\n }\n }\n }\n\n validate(c: AbstractControl): {[key: string]: any} {\n return this.validator(c);\n }\n\n registerOnValidatorChange(fn: () => void): void {\n this.onChange = fn;\n }\n}\n","import { AbstractControl, Validators, ValidatorFn } from '@angular/forms';\n\nimport { isPresent } from '../util/lang';\n\nexport const range = (range: Array