validate<T> method

TurboResponse<T>? validate<T>()

Validates the object's data before writing to Firestore.

Returns a TurboResponse with error details if the validation fails, or null if the object is valid and can be written to Firestore.

The type parameter T allows for returning specific error data types when validation fails.

Example:

@override
TurboResponse<String>? validate<String>() {
  if (!isValid) {
    return TurboResponse.fail(
      message: 'Validation failed',
      data: 'Custom error data'
    );
  }
  return null;
}

Implementation

TurboResponse<T>? validate<T>() => null;