I have a checkbox grid that has a combination of AccountIds (with x number of digits) and file names as values. Each pair of values is delimited with a pipe.
The file names will always start with PRC or FE and then a various combination of letters.
'{accountId}|{fileName}'
Validation Rule: No AccountIds can have > 1 file name type (PRC or FE)
['123|PRC1', '123|FE1'] // Good
['123|PRC1', '123|PRC2'] // BAD b/c 2 PRC filename types with same accountId
['123|FE1', '123|FE2'] // BAD b/c 2 FE filenames types with same accountId
const checkedItems = [
'12345|PRC-3343',
'12345|FELMP',
'567892|PRC-3343',
'567892|FEIIO',
'12345|PRCNOWAY'
];
// Dataset should have false returned from a validation method
// It is invalid because there are two PRC files with accountId 12345
validateForm(checkedItems: string[]) {
// find dups
}
formValid = this.validateForm(checkedItems);
Your help is very much appreciated. I am pretty much looking for an optimized way of finding out if form values are valid or not. Thank you.