mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
fixes
This commit is contained in:
committed by
Aiden McClelland
parent
88ed581d95
commit
f3190cc68f
@@ -119,6 +119,8 @@ export class FormService {
|
||||
private numberValidators (spec: ValueSpecNumber | ListValueSpecNumber): ValidatorFn[] {
|
||||
const validators: ValidatorFn[] = []
|
||||
|
||||
validators.push(isNumber())
|
||||
|
||||
if (!(spec as ValueSpecNumber).nullable) {
|
||||
validators.push(Validators.required)
|
||||
}
|
||||
@@ -160,6 +162,14 @@ export function numberInRange (stringRange: string): ValidatorFn {
|
||||
}
|
||||
}
|
||||
|
||||
export function isNumber (): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationErrors | null => {
|
||||
return control.value == Number(control.value) ?
|
||||
null :
|
||||
{ invalidNumber: { value: control.value } }
|
||||
}
|
||||
}
|
||||
|
||||
export function isInteger (): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationErrors | null => {
|
||||
return control.value == Math.trunc(control.value) ?
|
||||
|
||||
Reference in New Issue
Block a user