UNPKG

ng-jhipster

Version:

A Jhipster util library for Angular 2

30 lines (29 loc) 1.14 kB
import { Directive, Input } from '@angular/core'; import { NG_VALIDATORS } from '@angular/forms'; import { forwardRef } from '@angular/core'; import { numberOfBytes } from './number-of-bytes'; export var MaxbytesValidatorDirective = (function () { function MaxbytesValidatorDirective() { } MaxbytesValidatorDirective.prototype.validate = function (c) { return (c.value && numberOfBytes(c.value) <= this.jhiMaxbytes) ? null : { maxbytes: { valid: false } }; }; MaxbytesValidatorDirective.decorators = [ { type: Directive, args: [{ selector: '[jhiMaxbytes][ngModel]', providers: [ { provide: NG_VALIDATORS, useExisting: forwardRef(function () { return MaxbytesValidatorDirective; }), multi: true } ] },] }, ]; /** @nocollapse */ MaxbytesValidatorDirective.ctorParameters = function () { return []; }; MaxbytesValidatorDirective.propDecorators = { 'jhiMaxbytes': [{ type: Input },], }; return MaxbytesValidatorDirective; }());