From 76fa838ef2d78e44afed1eb4815471d8fdff9a4c Mon Sep 17 00:00:00 2001 From: Morgan Martin Date: Mon, 25 Sep 2017 14:18:14 -0700 Subject: [PATCH] Null input fix (#95) * Fixes for null inputs * Fix for gulp-rollup / rollup version conflicts * Fix for undefined going into regex --- package.json | 2 +- src/inputs/input-base.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d62db00..60607c2 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "gulp-inline-ng2-template": "^4.0.0", "gulp-ngc": "^0.3.2", "gulp-rename": "^1.2.2", - "gulp-rollup": "^2.14.0", + "gulp-rollup": "2.14.0", "gulp-typescript": "^3.2.2", "jasmine-core": "^2.6.4", "karma": "^1.7.0", diff --git a/src/inputs/input-base.ts b/src/inputs/input-base.ts index cfe50a0..399ea9f 100644 --- a/src/inputs/input-base.ts +++ b/src/inputs/input-base.ts @@ -162,7 +162,7 @@ export class InputBase implements OnInit, OnChanges, DoCheck, const { value } = this.state.getState(); if (this.canTestRegex(this.config)) { - if (!new RegExp(this.config.pattern as string).test(value)) { + if (!new RegExp(this.config.pattern as string).test(value != null && value !== false ? value : '')) { errs.push({ type: "PATTERN_ERROR", message: "Test pattern has failed", @@ -172,7 +172,7 @@ export class InputBase implements OnInit, OnChanges, DoCheck, if (this.canTestLength(this.config)) { const { min, max } = this.config; - const length = this.isNumeric ? Number(value) : value.length; + const length = value ? (this.isNumeric ? Number(value) : value.length) : 0; if (length < min || length > max) { errs.push({