ipv6
Validate that a string is a valid IPv6 address. Accepts full and compressed forms.
Signature
NguardValidators.String.ipv6: ValidatorFn
A parameterless validator — used directly without invocation.
Reactive forms
import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';
const address = new FormControl('', [NguardValidators.String.ipv6]);
Template-driven forms
<input ngModel name="address" nguardIpv6 />
Error key
{ ipv6: true }
Notes
- Accepts:
- Full form (
2001:0db8:85a3:0000:0000:8a2e:0370:7334) - Compressed form (
2001:db8::1) - Loopback (
::1) - Unspecified (
::)
- Full form (
- IPv4-mapped IPv6 (
::ffff:192.0.2.1) is not supported by the bundled regex. - IPv4 addresses fail — use
ipv4oripfor those. - Empty strings fail.