Skip to main content
Version: 0.7.0

declined

Validate that the value is one of the declined values (Laravel parity). The mirror of accepted — useful for opt-out toggles or "I do not agree" controls.

Signature

NguardValidators.Boolean.declined: ValidatorFn
Accepted inputNotes
falsenative boolean
'false'stringified boolean
0numeric false
'0'stringified numeric false
'no'lowercase string
'off'lowercase string (matches checkbox HTML)

The check is case-sensitive'No' and 'OFF' are not accepted. Anything outside the list above fails.

Reactive forms

import { FormControl, FormGroup } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';

const form = new FormGroup({
optedOut: new FormControl(false, [NguardValidators.Boolean.declined]),
});

Template-driven forms

<input type="checkbox" ngModel name="optedOut" nguardDeclined />

Error key

{ declined: true }

Notes

  • Match Laravel's declined rule exactly. If you need looser semantics (e.g. accept any falsy JS value), use falsy.
  • Pair with declinedIf when the requirement is conditional on a sibling field.

See also