I have a service which returns a value representing the money user has, and I want the user to be able to do transactions for a value equal or less than the total amount of money. I've tried to use max validation like this:
valid() {
const form: FormGroup = this._fb.group({
fond: ['', [Validators.required]],
serie: ['', [Validators.required]],
account: ['', [Validators.required, Validators.min(1)]],
value: ['', [Validators.required, Validators.min(1)]],
subAccount: ['', [Validators.required, Validators.min(1)]]
});
return form;
}
But it won't work, it seems like the value in max()
has to be set from the beginning, so it will just assume totalAmount as undefined.
max()
in it. By editing and removing that you are making your post very confusing to understand. Would strongly recommend you add back how you were attempting to usemax
before. – BalkanizeValidators.max(this.totalAmount)
– Mastersinger