UriValidator class abstract interface

An abstract validator for URI/URL validation.

This provides a contract for validating URIs and returning appropriate error messages when validation fails. Implement this to create custom URI validation logic.

Example Usage:

class HttpUriValidator implements UriValidator {
  @override
  bool isValid(Uri uri) => uri.scheme == 'http' || uri.scheme == 'https';

  @override
  String get errorMessage => 'Must be a valid HTTP/HTTPS URL';
}

void main() {
  final validator = HttpUriValidator();
  final uri = Uri.parse('https://example.com');
  
  if (!validator.isValid(uri)) {
    print(validator.errorMessage);
  }
}
Implementers

Properties

errorMessage String
Gets the error message to display when validation fails.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isValid(Uri uri) bool
Validates whether the given URI meets specific criteria.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited