angular-jsf-components
Version:
JSF Compliant Angular Components
31 lines (27 loc) • 794 B
text/typescript
import {Component, ElementRef, Input} from '@angular/core';
import {isEmpty} from 'lodash';
import {JsfCore} from '../../superclass/jsf-core';
({
selector: 'f-validate-regex',
templateUrl: './f-validate-regex.component.html',
styleUrls: ['./f-validate-regex.component.css'],
})
export class FValidateRegexComponent extends JsfCore {
()
pattern: string;
constructor(elementRef: ElementRef) {
super(elementRef);
}
/**
* checks string for regular expression
* @param {string} content
* @returns {boolean} true when regex ok
*/
validate(content: string): boolean {
if (!isEmpty(content)) {
return content.match(this.pattern) !== null;
} else {
return true;
}
}
}