Open ghost opened 4 years ago
export class TestInfo{ @prop() id: string;
@required() @email({ message: 'Invalid email' }) email: string;
@required() type: string;
@prop() primary: boolean;
@prop() changeType: string;
@prop() verified: boolean;
@prop() verifiedDate: string;
@prop() allowEdit: string; @prop() allowDelete: string; @prop() markedForDeletion: string; }
export class TestInfoDetails {
// I want to add custom validator(atleastOnePrimary below validator) for this formArray.
@propArray(TestInfo)
items: Array
// Validator: public static atleastOnePrimary() { const validator: ValidatorFn = (formArray: FormArray) => { const primaryList = formArray.controls.filter( (group: FormGroup) => group.controls.primary.value === true && group.controls.markedForDeletion.value !== true );
return primaryList && primaryList.length === 1 ? null : { onePrimary: false };
};
return validator;
}
@ram54118 Please share the code snippet.