Closed peterhe2000 closed 4 years ago
Read about updating-arrays and validation:
const validateAndUpdateFormState = updateGroup<MyFormValue>({
someNumbers: updateArray(updateGroup({
memberNumber: validate(required),
amount: validate(required, greaterThan(0)),
}))
});
Everything else you pointed looks standard.
Thanks @dzonatan for prompt reply. I tried your suggestion. I got compile error in following.
const validateAndUpdateFormState = updateGroup<MyFormValue>({
someNumbers: updateArray({
memberNumber: validate(required), // compile error
amount: validate(required, greaterThan(0)),
})
});
Sorry. Missed updateGroup
inside updateArray
. (I'm writing this straight from my head)
const validateAndUpdateFormState = updateGroup<MyFormValue>({
someNumbers: updateArray(
updateGroup({
memberNumber: validate(required),
amount: validate(required, greaterThan(0)),
})
),
});
@dzonatan That works. I can keep on my POC now. Appreciated for the help.
Thanks @dzonatan for helping out.
@peterhe2000 I you encounter any more difficulties during your POC please don't hesitate to open a new issue.
@MrWolfZ Will do.
Hi. There. First , thanks for the awesome library. I do like the fact the library build with pure function which angular native form is not. I am in a POC stage of a project which use a lot of angular form array. I am trying to get my head around how to use ngrx-form library.
Requirement is:
Here are code i come up so far. I am not sure whether i am on the right track. Could someone point me to the right direction in validation part? I got idea from https://ngrx-forms.readthedocs.io/en/master/user-guide/updating-the-state/