UNPKG

ngx-form-validator

Version:

A library for form validator specifically for Angular 2+ Usage for Reactive Forms

2 lines 2.76 kB
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs/index"),require("rxjs/internal/operators"),require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-form-validator",["exports","rxjs/index","rxjs/internal/operators","@angular/core","@angular/common"],e):e(n["ngx-form-validator"]={},n.rxjs.index,n.rxjs["internal/operators"],n.ng.core,n.ng.common)}(this,function(n,e,t,r,o){"use strict";var i=function(){function n(){this.destroy$=new e.Subject}return n.prototype.ngOnInit=function(){this.initControl()},n.prototype.initControl=function(){var e=this;this.control.statusChanges.pipe(t.takeUntil(this.destroy$)).subscribe(function(n){e.error=e.control.errors?window.Object.keys(e.control.errors)[0]:null}),this.error=this.control.errors?window.Object.keys(this.control.errors)[0]:null},n.prototype.ngOnDestroy=function(){this.destroy$.next(!0),this.destroy$.unsubscribe()},n.decorators=[{type:r.Component,args:[{selector:"ngx-form-validator",template:'\n <div *ngIf="control?.invalid && control?.touched"\n class="alert-text"\n >\n <div [ngSwitch]="error">\n <div *ngSwitchCase="\'required\'"><div>Required field</div></div>\n <div *ngSwitchCase="\'maxlength\'">\n <div\n *ngIf="control.errors.maxlength.requiredLength; else maxLength_zero"\n >\n Must contain from 1 to\n {{ control.errors.maxlength.requiredLength }} symbols\n </div>\n <ng-template #maxLength_zero>\n Must contain at least\n {{ control.errors.maxlength.requiredLength }} symbols\n </ng-template>\n </div>\n <div *ngSwitchCase="\'minlength\'">\n Must contain at least\n {{ control.errors.minlength.requiredLength }} symbols\n </div>\n <div *ngSwitchCase="\'email\'">Enter a valid Email</div>\n <div *ngSwitchCase="\'pattern\'">\n Enter a valid {{ propName || \'value\' }}\n </div>\n <div *ngSwitchDefault>Required correct field</div>\n </div>\n </div>\n ',styles:["\n .alert-text {\n position: absolute;\n width: 100%;\n text-align: right;\n color: #980000;\n background-color: transparent;\n font-size: 13px;\n }\n "]}]}],n.ctorParameters=function(){return[]},n.propDecorators={control:[{type:r.Input}],propName:[{type:r.Input}]},n}(),s=function(){function n(){}return n.decorators=[{type:r.NgModule,args:[{declarations:[i],imports:[o.CommonModule],exports:[i]}]}],n}();n.NgxFormValidatorComponent=i,n.NgxFormValidatorModule=s,Object.defineProperty(n,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-form-validator.umd.min.js.map