angular-compare-validator
v0.2.0
Published
Angular form validation directive to compare two inputs
Downloads
381
Readme
angular-compare-validator
This is a small Angular directive that supports form input validation for equal values, e.g. for password and comparePassword fields. It's automatically updated when either the source or destination value is changed.
Usage
Installation
Install via npm
npm install angular-compare-validator --save
Include the directive in your app.module.ts
import { CompareValidatorModule } from 'angular-compare-validator';
@NgModule({
imports: [
CompareValidatorModule
]
})
export class AppModule {
}
Include it in your view
<input type="password" name="passwordInput" [(ngModel)]="password" />
<input type="password" name="confirmPasswordInput" [compareEqual]="password" [(ngModel)]="confirmPassword" />
<span *ngIf="confirmPasswordInput.errors && confirmPasswordInput.errors.compareEqual">
Passwords do not match
</span>
Demo
Build
Run prepublish.ps1
to generate build output in the ./dist
folder.
Test
To run tests, execute the test.ps1
script. JUnit test results are then found in karma-results.xml
while coverage is available in the Cobertura format at coverage/PhantomJS/typescript.coverageresult
.