Validating integer and decimal


#1

Hi all,

I have created a custom validator to verify that an number being supplied is either an integer or an decimal, the problem I am having is that if an input like 1.1.1.1 is given the value on the control itself returns an empty string: “”

Is this an issue, or am I doing something wrong. Here is my validation code:
static isValid(control: FormControl): any {
–var x = control.value;
–if (isNaN(control.value)) {
----return {
------“not number”: true
----};
–}
–if (control.value % 1 !== 0) {
----return {
------“not integer”: true
----};
–}
–return null;
}