Giter Site home page Giter Site logo

yuyang041060120 / ng2-validation Goto Github PK

View Code? Open in Web Editor NEW
610.0 30.0 211.0 3.91 MB

angular2 validation

Home Page: https://yuyang041060120.github.io/ng2-validation/index.html

License: MIT License

TypeScript 80.83% HTML 14.79% JavaScript 4.18% CSS 0.20%
angular2 validation

ng2-validation's Introduction

Deprecated, you can fork and publish yours.

Description

Angular2 custom validation, inspired by jQuery validation.

Install

npm install ng2-validation --save

Systemjs

'ng2-validation': 'npm:ng2-validation/bundles/ng2-validation.umd.js'

Validators

angular2 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
  • phone
  • uuid
  • equal
  • notEqual
  • equalTo
  • notEqualTo

Usage

template driven

import FormsModule and CustomFormsModule in app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { CustomFormsModule } from 'ng2-validation'

import { AppComponent } from './app.component';

@NgModule({
    imports: [BrowserModule, FormsModule, CustomFormsModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {
}

rangeLength

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" [rangeLength]="[5, 9]"/>
<p *ngIf="field.errors?.rangeLength">error message</p>

min

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [min]="10"/>
<p *ngIf="field.errors?.min">error message</p>

gt

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [gt]="10"/>
<p *ngIf="field.errors?.gt">error message</p>

gte

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [gte]="10"/>
<p *ngIf="field.errors?.gte">error message</p>

max

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [max]="20"/>
<p *ngIf="field.errors?.max">error message</p>

lt

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [lt]="20"/>
<p *ngIf="field.errors?.lt">error message</p>

lte

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [lte]="20"/>
<p *ngIf="field.errors?.lte">error message</p>

range

<input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [range]="[10, 20]"/>
<p *ngIf="field.errors?.range">error message</p>

digits

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" digits/>
<p *ngIf="field.errors?.digits">error message</p>

number

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" number/>
<p *ngIf="field.errors?.number">error message</p>

url

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" url/>
<p *ngIf="field.errors?.url">error message</p>

email

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" email/>
<p *ngIf="field.errors?.email">error message</p>

date

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" date/>
<p *ngIf="field.errors?.date">error message</p>

minDate

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" minDate="2016-09-09"/>
<p *ngIf="field.errors?.minDate">error message</p>

maxDate

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" maxDate="2016-09-09"/>
<p *ngIf="field.errors?.maxDate">error message</p>

dateISO

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" dateISO/>
<p *ngIf="field.errors?.dateISO">error message</p>

creditCard

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" creditCard/>
<p *ngIf="field.errors?.creditCard">error message</p>

json

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" json/>
<p *ngIf="field.errors?.json">error message</p>

base64

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" base64/>
<p *ngIf="field.errors?.base64">error message</p>

phone

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" phone="CN"/>
<p *ngIf="field.errors?.phone">error message</p>

details see libphonenumber

uuid

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" [uuid]="'all'"/>
<p *ngIf="field.errors?.uuid">error message</p>

default: all

support

  • 3
  • 4
  • 5
  • all

equal

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" [equal]="'xxx'"/>
<p *ngIf="field.errors?.equal">error message</p>

equal

<input type="text" [(ngModel)]="model.field" name="field" #field="ngModel" [notEqual]="'xxx'"/>
<p *ngIf="field.errors?.notEqual">error message</p>

equalTo

<input type="password" ngModel name="password" #password="ngModel" required/>
<p *ngIf="password.errors?.required">required error</p>
<input type="password" ngModel name="certainPassword" #certainPassword="ngModel" [equalTo]="password"/>
<p *ngIf="certainPassword.errors?.equalTo">equalTo error</p>

notEqualTo

<input type="text" ngModel name="password" #password="ngModel" required/>
<p *ngIf="password.errors?.required">required error</p>
<input type="password" ngModel name="certainPassword" #certainPassword="ngModel" [notEqualTo]="password"/>
<p *ngIf="certainPassword.errors?.equalTo">equalTo error</p>

model driven

import ReactiveFormsModule in app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule } from '@angular/forms';

import { AppComponent } from './app.component';

@NgModule({
    imports: [BrowserModule, ReactiveFormsModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {
}

import CustomValidators in app.component.ts

import { Component } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';

@Component({
    selector: 'app',
    template: require('./app.html')
})
export class AppComponent {
    form: FormGroup;

    constructor() {
        this.form = new FormGroup({
            field: new FormControl('', CustomValidators.range([5, 9]))
        });
    }
}
<input type="text" formControlName="field"/>
<p *ngIf="demoForm.from.controls.field.errors?.rangeLength">error message</p>

rangeLength

new FormControl('', CustomValidators.rangeLength([5, 9]))

min

new FormControl('', CustomValidators.min(10))

gt

new FormControl('', CustomValidators.gt(10))

max

new FormControl('', CustomValidators.max(20))

lt

new FormControl('', CustomValidators.lt(20))

range

new FormControl('', CustomValidators.range([10, 20]))

digits

new FormControl('', CustomValidators.digits)

number

new FormControl('', CustomValidators.number)

url

new FormControl('', CustomValidators.url)

email

new FormControl('', CustomValidators.email)

date

new FormControl('', CustomValidators.date)

minDate

new FormControl('', CustomValidators.minDate('2016-09-09'))

maxDate

new FormControl('', CustomValidators.maxDate('2016-09-09'))

dateISO

new FormControl('', CustomValidators.dateISO)

creditCard

new FormControl('', CustomValidators.creditCard)

json

new FormControl('', CustomValidators.json)

base64

new FormControl('', CustomValidators.base64)

phone

new FormControl('', CustomValidators.phone('zh-CN'))

uuid

new FormControl('', CustomValidators.uuid('3'))

equal

new FormControl('', CustomValidators.equal('xxx'))

notEqual

new FormControl('', CustomValidators.notEqual('xxx'))

equalTo

let password = new FormControl('', Validators.required);
let certainPassword = new FormControl('', CustomValidators.equalTo(password));

this.form = new FormGroup({
  password: password,
  certainPassword: certainPassword
});
<form [formGroup]="form">
  <input type="password" formControlName="password"/>
  <p *ngIf="form.controls.password.errors?.required">required error</p>
  <input type="password" formControlName="certainPassword"/>
  <p *ngIf="form.controls.certainPassword.errors?.equalTo">equalTo error</p>
</form>

notEqualTo

let password = new FormControl('', Validators.required);
let certainPassword = new FormControl('', CustomValidators.notEqualTo(password));

this.form = new FormGroup({
  password: password,
  certainPassword: certainPassword
});
<form [formGroup]="form">
  <input type="password" formControlName="password"/>
  <p *ngIf="form.controls.password.errors?.required">required error</p>
  <input type="password" formControlName="certainPassword"/>
  <p *ngIf="form.controls.certainPassword.errors?.notEqualTo">notEqualTo error</p>
</form>

License

MIT

ng2-validation's People

Contributors

biosin avatar ccreighton-apptio avatar chrisgriffith avatar chuvisco88 avatar ert78gb avatar nick-triller avatar rafaelss95 avatar sefininio avatar yuyang041060120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng2-validation's Issues

ERROR in CustomFormsModule is not an NgModule

I know this has been reported before, but i just need ASAP clarification if the problem is bug with the module implementation or it's an ng-cli / webpack bug?

I'm on those versions
"angular-cli": "1.0.0-beta.24",
"@angular/compiler-cli": "^2.3.1",
"typescript": "^2.0.10",
"@angular/common": "^2.3.1",

thanks

equalTo doesn't set ng-invalid

First of all; lovely package. Brillant!
Im having a small issue when using this code (simplified)

<div ngModelGroup="passwordGroup" equalTo>
    <label class="label" for="signUpPassword">Password</label>
    <input class="input" [(ngModel)]="signUpUser.password" id="signUpPassword" type="password" required #password/>
    <label class="label" for="signUpPasswordConfirm">Confirm password</label>
    <input class="input" [(ngModel)]="signUpUser.passwordConfirm" #passwordConfirm/>
</div>
<p *ngIf="signUpForm.form.controls.passwordGroup?.errors?.equalTo">equalTo error</p>
<p>password: {{password.className}}</p>
<p>passwordConfirm: {{passwordConfirm.className}}</p>

And the user inputs something that doesnt match, you get the 'equalTo error' but not the ng-invalid class on passwordConfirm/password

Screencapture includes some elements not displayed in example code
image

Is this expected? It this a bug?

More custom/detailed error messages on failed validation

Hi Yu,
Congrats on a fine library. I was using validator.js (https://www.npmjs.com/package/validator) but had some event issues with it so yours is welcome.

3 requests please:

  1. More detail message required from the validator

Consider your code below for min

/**

  • Validator that requires controls to have a value of a min value.
    */
    static min(min: number): ValidatorFn {
    return (control: AbstractControl): {[key: string]: any} => {
    if (isPresent(Validators.required(control))) return null;

    let v: number = control.value;
    return v >= min ? null : {'min': true};
    

    };
    }

Instead of return {'min': true} when the validation failed, why not return

{'min': {'min': true, message: 'Minimun value ALLOWED is ${min}}

So we could access the error message like so: min.message or min['message']

Or you could simply return the message when the validation fails.

  1. If you CANNOT do 1), would it be possible for you to expose an isMin(number) or its eqivalent to allow us to use it to generate out own custom messages

  2. Any intention to expand your library to include other validators such as those in https://www.npmjs.com/package/validator?

Thanks and congrats again and let me know what you think,

Not AOT Friendly

As noted here and in other places, Angular2 modules need some extra configs to work with Ahead of Time compilation. ng2-validation does not work with AoT, throwing a similar error to the others in the linked issue.

Error: Unexpected value 'CustomFormsModule' imported by the module 'AppModule'
    at /var/www/www.rf.se/node_modules/@angular/compiler/bundles/compiler.umd.js:14326:37

Don't let user leave input if it doesn't validate

Say for example I have a html number input:

<input type="number">

This does not pyhsically let a user input text, other than numbers.

If I use the number validator with this plugin, text entry is allowed, it just displays a warning. Is there anyway to make ng2-validation disable entry into a form input, if it doesn't match the validation string?

minDate ... Issue with validating against Today

Thanks for your library... loving it. Hence why I'm taking the time to write the issue. Maybe I can even dig in around it... we'll see.

So I'm trying to set the minDate today as that's what I have on my control itself... Here's how I'm calculating today that is now working... I don't think I need the time indicators, but added for "safety".

    // Set the time to ensure that anytime today is okay.
    let today: Date = new Date();
    today.setDate(today.getDate() -1);
    today.setHours(0);
    today.setMinutes(0);
    today.setSeconds(0);
    let tomorrow: Date = new Date();
    tomorrow.setDate(today.getDate() + 1);
    tomorrow.setHours(0);
    tomorrow.setMinutes(0);
    tomorrow.setSeconds(0);

    // ... left out code for brevity
    CustomValidators.minDate(today)
    CustomValidators.minDate(tomorrow)

When done this way I am able to choose today and tomorrow. However, what I had previously was... and I expected this to work, and it doesn't.

    // Set the time to ensure that anytime today is okay.
    let today: Date = new Date();
    today.setHours(0);
    today.setMinutes(0);
    today.setSeconds(0);
    let tomorrow: Date = new Date();
    tomorrow.setDate(today.getDate() + 1);
    tomorrow.setHours(0);
    tomorrow.setMinutes(0);
    tomorrow.setSeconds(0);

    // ... left out code for brevity
    CustomValidators.minDate(today)
    CustomValidators.minDate(tomorrow)

The date output from console.log for the first one is yesterday and today as the minDate values. The date output from console.log for the second example is today and tomorrow as the minDate.

If I'm doing something wrong or just misunderstood, then please let me know... at the least, I think this should get a Documentation PR. Look forward to your remarks.

breaks in angular-cli: 1.0.0-beta.22-1

Error: CustomFormsModule is not an NgModule
at AotPlugin.getNgModuleMetadata (D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:332:19)
at D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:345:51
at Array.map (native)
at AotPlugin.extractLoadChildren (D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:343:14)
at D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:346:30
at Array.map (native)
at AotPlugin.extractLoadChildren (D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:343:14)
at AotPlugin._processNgModule (D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:272:38)
at D:\Lab\Temp\MyProject\ng2\MyProject\node_modules@ngtools\webpack\src\plugin.js:242:39
at process._tickCallback (internal/process/next_tick.js:103:7)

Add AoT compilation support in Angular-2

Please add support for AoT compilation. It fails right now with the error

Unexpected value 'CustomFormsModule' imported by the module

ng build --prod --env=prod --aot
10% building modules 2/2 modules 0 active Unexpected value 'CustomFormsModule' imported by the module 'MyModule'

I guess metadata.json files are missing from the library which are required by ngc.
Similar issue in ng2-bootstrap

I'm using angular-cli 1.0.0-beta.21 right now, since latest has some compiler issues as described in #28. But I believe this problem is independent from this. This may also solve #28

Export all directives in index.d.ts

Right now, the index.d.ts of the npm package looks like:

export * from './custom-validators';
export * from './directives';

and directives.d.ts looks completely empty. So if I want to use the Validators there, I cannot import them nicely.

How to apply HTML5 min/max attributes along with min/max directive?

Cannot apply HTML5 min/max attributes along with directive for input[type="number"].

Examples:
<input type="number" min="0" max="10">
Result: HTML5 attributes applied, ng2-validation directives are NOT applied.

<input type="number" [min]="0" [max]="10">
Result: HTML5 attributes NOT applied, ng2-validation directives are applied.

Is there a way to apply HTML5 attributes using values from expression?
Is there a way to apply HTML5 attributes along with ng2-validation directives?

Template parse errors when using the example template

Template:
`<input type="text" [(ngModel)]="field" name="field" #field="ngModel" [rangeLength]="[5, 9]"/>

error message

`

Error:
`Error: Template parse errors:
Can't bind to 'rangeLength' since it isn't a known property of 'input'. ("<input type="text" [(ngModel)]="field" name="field" #field="ngModel" [ERROR ->][rangeLength]="[5, 9]"/>

error message

"): LoginComponent@0:69`

Help, please.

notEqualTo validation

A validator I'm using quite frequently for inputting new passwords:

Current password: [ xyz ]
New password: [ xyz ]

Error! New password must be different than current

notEqual validator is not working

I tried [notEqual]="'0'" and [notEqual]="0" with *ngIf="amount?.errors?.notEqual" but I got this error message from angular "Can't bind to 'notEqual' since it isn't a known property of 'input'. "

Not working in angular-seed

I tried integrating the ng2-validation in my angular-seed based project.
for ref: https://github.com/mgechev/angular-seed
I am getting the following error when i import the CustomFormsModule.

"(SystemJS) Unexpected token <
SyntaxError: Unexpected token <
at Object.eval (http://localhost:5555/node_modules/ng2-validation/dist/directives/range-length.js:13:10)
at eval (http://localhost:5555/node_modules/ng2-validation/dist/directives/range-length.js:43:4)
at eval (http://localhost:5555/node_modules/ng2-validation/dist/directives/range-length.js:44:3)
Evaluating http://localhost:5555/node_modules/ng2-validation/dist/
Evaluating http://localhost:5555/node_modules/ng2-validation/dist/directives/range-length.js
Evaluating http://localhost:5555/node_modules/ng2-validation/dist/directives.js
Evaluating http://localhost:5555/node_modules/ng2-validation/dist/index.js
Evaluating http://localhost:5555/app/app.module.js
Evaluating http://localhost:5555/app/main.js
Error loading http://localhost:5555/app/main.js"

I am getting the same error for both template driven and reactive forms. Please help me in this regard.

Please check my code what I ve done wrong with Template Driven (TT)

I'm doing on form validation and I'm trying to use min validator, no error, but it's not working.

my code as following
<form class="form-inline" name="form" (ngSubmit)="addEmployee(firstnameAdd.value, lastnameAdd.value, ageAdd.value, sexAdd.value) && aleart('Update successful.')" role="form" novalidate> <div class="form-group col-md-4"> <input type="text" class="form-control" #firstnameAdd placeholder="Firstname" required /> </div> <div class="form-group col-md-4"> <input type="text" class="form-control" #lastnameAdd placeholder="Lastname" required /> </div> <div class="form-group col-md-1"> <input type="number" class="form-control" #ageAdd placeholder="Age" required [(ngModel)]="addForm.age" name="age" #age="ngModel" [min]='1' /> <p *ngIf="age.errors?.min">error message</p> </div> <div class="form-group col-md-2"> <select class="form-control" #sexAdd> <option>Male</option> <option>Female</option> </select> </div> <div class="form-group"> <button type="submit" class="btn btn-primary btn-re-sm"> <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> </button> </div>

` addForm : FormGroup;

constructor(af: AngularFire) {
this.employees = af.database.list('/employees');
this.addForm = new FormGroup({
age: new FormControl('', CustomValidators.min(1)),
});
}`

but I can use as Model Driven like equalto example but it not change to the correct state.

Getting warnings about missing src files

I get a warning for each validator similiar to this:

./~/ng2-validation/dist/index.js
Cannot find source file '../src/index.ts': Error: Can't resolve '../src/index.ts' in '/var/www/moo/node_modules/ng2-validation/dist'

My guess is that the src folder is missing in the npm install

doesn't work ng2-bootstrap

i'm using ng2-bootstrap with bootstrap 4.
the datepicker works just fine. when i add datevalidation and validation errors are present the datepicker freaks out (see attached screenshot)
bildschirmfoto 2016-10-03 um 13 42 11

as long theres no validation error datepicker behaves normal
bildschirmfoto 2016-10-03 um 13 44 23

package.json

{
"name": "web2",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint "src/*/.ts"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"core-js": "^2.4.1",
"ng2-bootstrap": "^1.1.5",
"ng2-cookies": "^1.0.2",
"ng2-validation": "^2.0.0",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.15",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
}
}

minDate throws error

I added an input as the following:

<input class="m-form-control m-form-control-sm"
            id="activateDate"
            name="activateDate"
            required
            type="date"
            [(ngModel)]="editableGiftcardActivateDate"
            [minDate]="minActivationDate | date: 'y-MM-dd'"
            #activateDate="ngModel">

Even if I replace the minDate with a fixed value I get the error

TypeError: lang_1.isDate is not a function
    at Object.exports.minDate (http://localhost:3000/vendor.bundle.js:20965:17)
    at MinDateValidator.ngOnChanges (http://localhost:3000/vendor.bundle.js:20928:37)
    at Wrapper_MinDateValidator.ngDoCheck (/CustomFormsModule/MinDateValidator/wrapper.ngfactory.js:29:20)

Not sure how to fix this, can you provide some assistance?

Angular X Support

I would love to see ng2-validation actually support validation in all future versions of angular. Unfortunately the name itself may be useful to change, but ultimately I like to move forward to latest and greatest if I'm not already in production... so I tried and I'm having failures with ng2. I would love to help with this process, but I'm unable to figure out how to get the system setup for development. I'm primarily a backend developer.

Thanks!

does not export CustomFormsModule error

Hi, I have install lib. but it's giving following error

\node_modules\ng2-validation\dist\index.js does not export CustomFormsModule (imported by C:\MyApp.tmp\app\app.module.js)

not working with angular2 final release

I've runned : npm install ng2-validation --save
then, imported FormsModule and CustomFormsModule in app.module.ts
But when I set CustomFormsModule in @NgModule({ imports: [])} it throws an error !

zone.js:1382 GET http://localhost:3002/ng2-validation 404 (Not Found)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM5420:3fetchTextFromURL @ system.src.js:1156(anonymous function) @ system.src.js:1739ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1738(anonymous function) @ system.src.js:2764(anonymous function) @ system.src.js:3338(anonymous function) @ system.src.js:3605(anonymous function) @ system.src.js:3990(anonymous function) @ system.src.js:4453(anonymous function) @ system.src.js:4705(anonymous function) @ system.src.js:408ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339XMLHttpRequest.send (async)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM5420:3fetchTextFromURL @ system.src.js:1156(anonymous function) @ system.src.js:1739ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1738(anonymous function) @ system.src.js:2764(anonymous function) @ system.src.js:3338(anonymous function) @ system.src.js:3605(anonymous function) @ system.src.js:3990(anonymous function) @ system.src.js:4453(anonymous function) @ system.src.js:4705(anonymous function) @ system.src.js:408ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401ZoneTask.invoke @ zone.js:339XMLHttpRequest.send (async)scheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ zone.js:245Zone.scheduleMacroTask @ zone.js:171(anonymous function) @ zone.js:1405send @ VM5420:3fetchTextFromURL @ system.src.js:1156(anonymous function) @ system.src.js:1739ZoneAwarePromise @ zone.js:518(anonymous function) @ system.src.js:1738(anonymous function) @ system.src.js:2764(anonymous function) @ system.src.js:3338(anonymous function) @ system.src.js:3605(anonymous function) @ system.src.js:3990(anonymous function) @ system.src.js:4453(anonymous function) @ system.src.js:4705(anonymous function) @ system.src.js:408ZoneDelegate.invoke @ zone.js:232Zone.run @ zone.js:114(anonymous function) @ zone.js:502ZoneDelegate.invokeTask @ zone.js:265Zone.runTask @ zone.js:154drainMicroTaskQueue @ zone.js:401Promise.resolve (async)scheduleQueueDrain @ zone.js:374scheduleMicroTask @ zone.js:382ZoneDelegate.scheduleTask @ zone.js:248Zone.scheduleMicroTask @ zone.js:168scheduleResolveOrReject @ zone.js:500ZoneAwarePromise.then @ zone.js:586(anonymous function) @ system.src.js:4663import @ system.src.js:872(anonymous function) @ system.src.js:1762(anonymous function) @ (index):80
(index):80 Error: Error: XHR error (404 Not Found) loading http://localhost:3002/ng2-validation(…)

Multiple Validators for the same input field.

I believe that it would be very useful to have a note about multiple validators for the same field.

I was able to accomplish this with:

this.myForm = fb.group({
  'cardNumber': new FormControl('', Validators.compose([Validators.required, CustomValidators.creditCard]))
});

Support for lazy value validation

I've got a minimum age required to register so I'm exposing that date to the view. If you change country then the minimum age required changes, and so the maxDate validation changes.

In order for the view to know a value changed, the date reference needs to change but unfortunately the reference is broken for maxDate validation.

I'm currently getting around this like:

function lazyMaxDateValidator(fn) {
  return function(control) {
    const d = new Date(control.value);
    const then = fn();
    return (d <= new Date(then)) ? null : { maxDate: true };
  }
}

Perhaps it would be good to support both a function and a date with min/maxDate and anything else that takes a reference?

Validating URLs with an underscore in the subdomain.

Currently, the URL parsing fails for any URL that includes a subdomain with an underscore. For example:
my_domain.scott.com

This isn't a completely straightforward issue, because technically underscores in subdomains aren't standards compliant -- even if it's used and tends to work in every browser.

@yuyang041060120 Would you accept a pull request to allow for underscores in the subdomain?

Date formats

i want to use a different date format i.e. DD-MM-YYYY for date, minDate, maxDate

Min/Max treating null or undefined as zero

Hi,

I am required to build a form dynamically using data from a json file.

I am using template driven forms and setting the Min and Max values based on the data in the json file.

If values for Min or Max are not provided the validators activate and treat the value as zero.

Is it possible for the Min/Max validators to ignore null or undefined values. In other words, do not try and validate.

Regards,
Tarek

Phone Validation Does Not Work

The email validation works great on my screen. However, the phone validation always displays "error message" for these valid phone numbers: 1-555-111-3333, 555-111-3333, or 5551113333. Here is the code that I used:

phonevalidate

Thank you in advance for your support.

Wen Hoang

Fail on load "[email protected]

Fail to use ng2-validators. The error I get:
GET http://localhost:8081/node_modules/ng2-validation/dist/base64.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 VM3609:27 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:8081/node_modules/ng2-validation/dist/base64.js Error: XHR error (404 Not Found) loading http://localhost:8081/node_modules/ng2-validation/dist/base64.js at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:8081/node_modules/zone.js/dist/zone.js:698:29) at ZoneDelegate.invokeTask (http://localhost:8081/node_modules/zone.js/dist/zone.js:265:35) at Zone.runTask (http://localhost:8081/node_modules/zone.js/dist/zone.js:154:47) at XMLHttpRequest.ZoneTask.invoke (http://localhost:8081/node_modules/zone.js/dist/zone.js:335:33) Error loading http://localhost:8081/node_modules/ng2-validation/dist/base64.js as "./base64" from http://localhost:8081/node_modules/ng2-validation/dist/index.js at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:8081/node_modules/zone.js/dist/zone.js:698:29) at ZoneDelegate.invokeTask (http://localhost:8081/node_modules/zone.js/dist/zone.js:265:35) at Zone.runTask (http://localhost:8081/node_modules/zone.js/dist/zone.js:154:47) at XMLHttpRequest.ZoneTask.invoke (http://localhost:8081/node_modules/zone.js/dist/zone.js:335:33) Error loading http://localhost:8081/node_modules/ng2-validation/dist/base64.js as "./base64" from http://localhost:8081/node_modules/ng2-validation/dist/index.js window.console.error @ VM3609:27 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/credit-card.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/date.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/date-ios.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/digits.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/email.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/equal.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/equal-to.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/greater-than.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/json.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/less-than.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/max.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/max-date.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/min.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/min-date.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/not-equal.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/not-equal-to.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/number.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/phone.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/range.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/range-length.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/url.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339 zone.js:1382 GET http://localhost:8081/node_modules/ng2-validation/dist/uuid.js 404 (Not Found) scheduleTask @ zone.js:1382 ZoneDelegate.scheduleTask @ zone.js:245 Zone.scheduleMacroTask @ zone.js:171 (anonymous) @ zone.js:1405 send @ VM3641:3 fetchTextFromURL @ system.src.js:1051 (anonymous) @ system.src.js:1778 ZoneAwarePromise @ zone.js:518 (anonymous) @ system.src.js:1777 (anonymous) @ system.src.js:2802 (anonymous) @ system.src.js:3380 (anonymous) @ system.src.js:3694 (anonymous) @ system.src.js:4086 (anonymous) @ system.src.js:4549 (anonymous) @ system.src.js:4819 (anonymous) @ system.src.js:407 ZoneDelegate.invoke @ zone.js:232 Zone.run @ zone.js:114 (anonymous) @ zone.js:502 ZoneDelegate.invokeTask @ zone.js:265 Zone.runTask @ zone.js:154 drainMicroTaskQueue @ zone.js:401 ZoneTask.invoke @ zone.js:339

I think it happens due to this line:
var base64_1 = require('./base64');
in file:
index.js
Happend on version:
""[email protected]", (ng2-validation-3.7.0.tgz_1487159437774_0.045551683055236936")

怎么使用

您好 看起来就简单几步,我使用angular-cli创建项目

  1. 安装
  2. 配置app.module.ts
  3. 配置模板
  4. 初始化变量

但是还是报错,请问还有其他东西需要安装,配置吗

min and max is not working correctly with input[text]

static min(min: number): ValidatorFn {
    return (control: AbstractControl): {[key: string]: any} => {
      if (isPresent(Validators.required(control))) return null;

      let v: number = control.value;
      console.log(typeof min);//string
      return v >= min ? null : {'min': true};
    };
  }

One solution would be to parseFloat(min)

No angular 2.0.0 yet

Hi,

Is there any way to use the ng2-validation without the CustomFormsModule ,
I dont use the ngModule yet , so i need a component and not the module.
I also tried to see in the history of your older commits but didnt find it .

Thanks.
Othman

Can't handle dynamically changing validation values

If I use a dynamically changing validation value, the validation doesn't rerun. Even if I use .updateValueAndValidity();, the validation remains in it's old state.
Reassigning a new value with CustomValidators.max(pagecount) e.g. helps but is far from ideal.

Another directive from here https://github.com/czeckd/angular2-minmax-validators/blob/master/app/minmax/min-value-validator.directive.ts is able to handle such scenario since it triggers the validation on changes.

Validator for Initials

Is there a way to validate a users initials?

i.e. validate whether the field value has one or multiple chars, separated by spaces or dots or both.

Conditional Null Field

Did you have a validation that makes a field required if another field is empty?
For example field1 and field2 have a conditional requried rule. So if field1 is null field2 is required or vice versa.

Extend CustomValidation

Can we extend CustomValidators classs with Validators class so we no longer have to import both of them, instead call only the custom one?

Request: Array length validation

Request: Array length validation

Looking for something like this
itemArray: [[], CustomValidators.arrayMinLength(1)]

by that, form control element 'itemArray' should contain at least one element in it for the form to be valid.
and as well as arrayMaxLength may also be useful

Validator for alphanumeric

  • Alphanumeric are used extensively.Please update for alphanumeric.

  • Also min and max can be applied for different controls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.