ng2-validation
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -16,2 +16,10 @@ import { ValidatorFn, AbstractControl } from '@angular/forms'; | ||
/** | ||
* Validator that requires controls to have a value greater than a gt value. | ||
*/ | ||
static gt(gt: number): ValidatorFn; | ||
/** | ||
* Validator that requires controls to have a value less than a lt value. | ||
*/ | ||
static lt(lt: number): ValidatorFn; | ||
/** | ||
* Validator that requires controls to have a value of a range value. | ||
@@ -18,0 +26,0 @@ */ |
@@ -41,2 +41,24 @@ "use strict"; | ||
/** | ||
* Validator that requires controls to have a value greater than a gt value. | ||
*/ | ||
CustomValidators.gt = function (gt) { | ||
return function (control) { | ||
if (lang_1.isPresent(forms_1.Validators.required(control))) | ||
return null; | ||
var v = control.value; | ||
return v > gt ? null : { 'gt': true }; | ||
}; | ||
}; | ||
/** | ||
* Validator that requires controls to have a value less than a lt value. | ||
*/ | ||
CustomValidators.lt = function (lt) { | ||
return function (control) { | ||
if (lang_1.isPresent(forms_1.Validators.required(control))) | ||
return null; | ||
var v = control.value; | ||
return v < lt ? null : { 'lt': true }; | ||
}; | ||
}; | ||
/** | ||
* Validator that requires controls to have a value of a range value. | ||
@@ -43,0 +65,0 @@ */ |
@@ -5,3 +5,5 @@ "use strict"; | ||
var min_1 = require('./directives/min'); | ||
var greater_than_1 = require('./directives/greater-than'); | ||
var max_1 = require('./directives/max'); | ||
var less_than_1 = require('./directives/less-than'); | ||
var range_1 = require('./directives/range'); | ||
@@ -27,3 +29,5 @@ var digits_1 = require('./directives/digits'); | ||
min_1.MinValidator, | ||
greater_than_1.GreaterThanValidator, | ||
max_1.MaxValidator, | ||
less_than_1.LessThanValidator, | ||
range_1.RangeValidator, | ||
@@ -30,0 +34,0 @@ digits_1.DigitsValidator, |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"CUSTOM_FORM_DIRECTIVES":[{"__symbolic":"reference","module":"./directives/range-length","name":"RangeLengthValidator"},{"__symbolic":"reference","module":"./directives/min","name":"MinValidator"},{"__symbolic":"reference","module":"./directives/max","name":"MaxValidator"},{"__symbolic":"reference","module":"./directives/range","name":"RangeValidator"},{"__symbolic":"reference","module":"./directives/digits","name":"DigitsValidator"},{"__symbolic":"reference","module":"./directives/number","name":"NumberValidator"},{"__symbolic":"reference","module":"./directives/url","name":"UrlValidator"},{"__symbolic":"reference","module":"./directives/email","name":"EmailValidator"},{"__symbolic":"reference","module":"./directives/date","name":"DateValidator"},{"__symbolic":"reference","module":"./directives/min-date","name":"MinDateValidator"},{"__symbolic":"reference","module":"./directives/max-date","name":"MaxDateValidator"},{"__symbolic":"reference","module":"./directives/date-iso","name":"DateISOValidator"},{"__symbolic":"reference","module":"./directives/credit-card","name":"CreditCardValidator"},{"__symbolic":"reference","module":"./directives/json","name":"JSONValidator"},{"__symbolic":"reference","module":"./directives/base64","name":"Base64Validator"},{"__symbolic":"reference","module":"./directives/phone","name":"PhoneValidator"},{"__symbolic":"reference","module":"./directives/uuid","name":"UUIDValidator"},{"__symbolic":"reference","module":"./directives/equal","name":"EqualValidator"},{"__symbolic":"reference","module":"./directives/equal-to","name":"EqualToValidator"},{"__symbolic":"reference","module":"./directives/not-equal-to","name":"NotEqualToValidator"}],"CustomFormsModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"CUSTOM_FORM_DIRECTIVES"}],"exports":[{"__symbolic":"reference","name":"CUSTOM_FORM_DIRECTIVES"}]}]}]}}} | ||
{"__symbolic":"module","version":1,"metadata":{"CUSTOM_FORM_DIRECTIVES":[{"__symbolic":"reference","module":"./directives/range-length","name":"RangeLengthValidator"},{"__symbolic":"reference","module":"./directives/min","name":"MinValidator"},{"__symbolic":"reference","module":"./directives/greater-than","name":"GreaterThanValidator"},{"__symbolic":"reference","module":"./directives/max","name":"MaxValidator"},{"__symbolic":"reference","module":"./directives/less-than","name":"LessThanValidator"},{"__symbolic":"reference","module":"./directives/range","name":"RangeValidator"},{"__symbolic":"reference","module":"./directives/digits","name":"DigitsValidator"},{"__symbolic":"reference","module":"./directives/number","name":"NumberValidator"},{"__symbolic":"reference","module":"./directives/url","name":"UrlValidator"},{"__symbolic":"reference","module":"./directives/email","name":"EmailValidator"},{"__symbolic":"reference","module":"./directives/date","name":"DateValidator"},{"__symbolic":"reference","module":"./directives/min-date","name":"MinDateValidator"},{"__symbolic":"reference","module":"./directives/max-date","name":"MaxDateValidator"},{"__symbolic":"reference","module":"./directives/date-iso","name":"DateISOValidator"},{"__symbolic":"reference","module":"./directives/credit-card","name":"CreditCardValidator"},{"__symbolic":"reference","module":"./directives/json","name":"JSONValidator"},{"__symbolic":"reference","module":"./directives/base64","name":"Base64Validator"},{"__symbolic":"reference","module":"./directives/phone","name":"PhoneValidator"},{"__symbolic":"reference","module":"./directives/uuid","name":"UUIDValidator"},{"__symbolic":"reference","module":"./directives/equal","name":"EqualValidator"},{"__symbolic":"reference","module":"./directives/equal-to","name":"EqualToValidator"},{"__symbolic":"reference","module":"./directives/not-equal-to","name":"NotEqualToValidator"}],"CustomFormsModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"CUSTOM_FORM_DIRECTIVES"}],"exports":[{"__symbolic":"reference","name":"CUSTOM_FORM_DIRECTIVES"}]}]}]}}} |
{ | ||
"name": "ng2-validation", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "angular2 validation", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -24,3 +24,5 @@ # Description | ||
- min | ||
- gt | ||
- max | ||
- lt | ||
- range | ||
@@ -81,2 +83,9 @@ - digits | ||
### gt | ||
```html | ||
<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [gt]="10"/> | ||
<p *ngIf="field.errors?.gt">error message</p> | ||
``` | ||
### max | ||
@@ -89,2 +98,9 @@ | ||
### lt | ||
```html | ||
<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [lt]="20"/> | ||
<p *ngIf="field.errors?.lt">error message</p> | ||
``` | ||
### range | ||
@@ -307,2 +323,8 @@ | ||
### gt | ||
```javascript | ||
new FormControl('', CustomValidators.gt(10)) | ||
``` | ||
### max | ||
@@ -314,2 +336,8 @@ | ||
### lt | ||
```javascript | ||
new FormControl('', CustomValidators.lt(20)) | ||
``` | ||
### range | ||
@@ -316,0 +344,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114043
108
1442
473