BloomRpcValidationErrors class

Structured field-level and general validation errors from an RPC error response.

Parses validation responses emitted by REST backends, including bloom_rest's BloomValidationErrors serializer output ({"errors": {"field": "msg"}} or {"field": ["msg"]}).

Provides field-level inspection methods and flattenedErrors for easy binding to UI form fields.

try {
  await client.call(createUserContract, newUserData);
} on BloomRpcHttpException catch (e) {
  if (e.isValidationError) {
    final errors = e.validationErrors;
    final emailError = errors?.firstError('email');
    print('Email error: $emailError');
  }
}

Constructors

BloomRpcValidationErrors({Map<String, List<String>> fieldErrors = const {}, List<String> nonFieldErrors = const []})
Creates a BloomRpcValidationErrors with structured field and general errors.
const
BloomRpcValidationErrors.fromResponse(dynamic data)
Parses validation errors from decoded response JSON or error maps.
factory

Properties

fieldErrors Map<String, List<String>>
Unmodifiable map of all field-level validation errors.
no setter
flattenedErrors Map<String, String>
Flattened map containing only the first error string per field.
no setter
generalError String?
First general error message, or null if none was recorded.
no setter
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether no validation errors were recorded.
no setter
isNotEmpty bool
Whether at least one validation error exists.
no setter
nonFieldErrors List<String>
Unmodifiable list of general / non-field validation errors.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

errorsFor(String field) List<String>?
Returns all error messages recorded for field, or null if none exist.
firstError(String field) String?
Returns the first error message for field, or null if none exists.
hasError(String field) bool
Whether validation errors exist for field.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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