Validation MinLength验证程序将0视为零长度
我有下面的代码来验证一个字段,这个字段保留数字值 当值为0时, 然后验证失败,因为minLength将0视为0长度 场景:我有一个折扣字段,它是HTML中必需的,最小长度为1 从角度看 它应该接受0,但在这种情况下,表单无效Validation MinLength验证程序将0视为零长度,validation,angular6,Validation,Angular6,我有下面的代码来验证一个字段,这个字段保留数字值 当值为0时, 然后验证失败,因为minLength将0视为0长度 场景:我有一个折扣字段,它是HTML中必需的,最小长度为1 从角度看 它应该接受0,但在这种情况下,表单无效 discount: new FormControl('', Validators.compose([ Validators.maxLength(5), Validators.minLength(1), ])), 我不想使用验证器。根据
discount: new FormControl('', Validators.compose([
Validators.maxLength(5),
Validators.minLength(1),
])),
我不想使用验证器。根据我的要求,我只需要使用minLength,它将来自数据库(到目前为止,我只是硬编码)
请帮忙
discount: new FormControl('', Validators.compose([
Validators.required
Validators.maxLength(5),
])),