Skip to content

Commit

Permalink
Null input fix (#95)
Browse files Browse the repository at this point in the history
* Fixes for null inputs

* Fix for gulp-rollup / rollup version conflicts

* Fix for undefined going into regex
  • Loading branch information
jmorganmartin authored and tonivj5 committed Sep 25, 2017
1 parent fdbf492 commit 76fa838
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/inputs/input-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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({
Expand Down

0 comments on commit 76fa838

Please sign in to comment.