Accepted
The Accepted rule confirms that the user has explicitly agreed to something — most commonly a terms-of-service checkbox, a privacy policy consent box, or a newsletter opt-in toggle. A field only passes this rule when its value is one of the recognized affirmative values: yes, on, 1, or true. Anything else — an empty string, false, null, 0, or undefined — is treated as not accepted, so an unchecked checkbox or an untouched field correctly fails validation instead of silently passing.
#Directive Code Snippet
<html lang="en">
...
<form (ngSubmit)="onSubmit(form)" #form="ngForm">
<input accepted type="text" name="<name>" [(ngModel)]="<name>" #<name>="ngModel">
<ng-absolute-validator [formInstance]="<name>"></ng-absolute-validator>
</form>
...
</html>
#Chain Rule Code Snippet
<!DOCTYPE html>
<html lang="en">
...
<form (ngSubmit)="onSubmit(form)" #form="ngForm">
<input [Rule]="accepted" type="text" name="<name>" [(ngModel)]="<name>" #<name>="ngModel">
<ng-absolute-validator [formInstance]="<name>"></ng-absolute-validator>
</form>
...
</html>
#Reactive Code Snippet
//component.ts
export class ReactiveComponent{
public form !: FormGroup;
constructor(
private fb : FormBuilder,
private rv : ReactiveValidator,
){this.generteForm()}
generteForm(){
this.form = this.fb.group({
<name> : ['',this.rv.map('accepted',<CUSTOM_MESSAGE>)],
})
}
}
//component.html
<!DOCTYPE html>
<html lang="en">
...
<form [formGroup]="form">
<input type="text" name="<name>" formControlName="<name>">
<ng-absolute-validator [formInstance]="form.get(<name>)"></ng-absolute-validator>
</form>
...
</html>