- + @@ -72,7 +76,7 @@ const INLINE_EDITOR_TEMPLATE = ` - +
@@ -155,7 +159,8 @@ export class InlineEditorComponent implements ControlValueAccessor, OnInit, Inpu @Input() public min: number; @Input() public max: number; @Input() public fnErrorLength; - + @Input() public pattern: string; + @Input() public fnErrorPattern; //textarea's attribute @Input() public cols: number = 50; @@ -214,6 +219,12 @@ export class InlineEditorComponent implements ControlValueAccessor, OnInit, Inpu this.fnErrorLength = typeof this.fnErrorLength !== 'undefined' ? this.fnErrorLength : inputConfig.fnErrorLength; + this.pattern = typeof this.pattern !== 'undefined' + ? this.pattern + : inputConfig.pattern; + this.fnErrorPattern = typeof this.fnErrorPattern !== 'undefined' + ? this.fnErrorPattern + : inputConfig.fnErrorPattern; if (this.type == "select") { @@ -276,7 +287,11 @@ export class InlineEditorComponent implements ControlValueAccessor, OnInit, Inpu // Method to display the editable value as text and emit save event to host onSubmit(value) { - if (value.length < this.min || value.length > this.max) { + let rExp = new RegExp(this.pattern); + if (!rExp.test(value)) { + this.fnErrorPattern(); + } + else if (value.length < this.min || value.length > this.max) { this.fnErrorLength(); } else { this.onSave.emit(value);