From ecfda8f23841b477589730e7264b5e4b8885318b Mon Sep 17 00:00:00 2001 From: exaby73 Date: Tue, 20 Feb 2024 15:13:42 +0530 Subject: [PATCH] feat: override toString for validation results --- .../luthor/lib/src/validation_result.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/luthor/lib/src/validation_result.dart b/packages/luthor/lib/src/validation_result.dart index 32e8c52a..0b7ece23 100644 --- a/packages/luthor/lib/src/validation_result.dart +++ b/packages/luthor/lib/src/validation_result.dart @@ -8,6 +8,16 @@ sealed class SingleValidationResult { SingleValidationError(data: _, errors: _) => false, }; } + + @override + String toString() { + return switch (this) { + SingleValidationSuccess(data: final data) => + 'SingleValidationSuccess(data: $data)', + SingleValidationError(data: final data, errors: final errors) => + 'SingleValidationError(data: $data, errors: $errors)', + }; + } } class SingleValidationSuccess extends SingleValidationResult { @@ -35,6 +45,16 @@ sealed class SchemaValidationResult { SchemaValidationError(data: _, errors: _) => false, }; } + + @override + String toString() { + return switch (this) { + SchemaValidationSuccess(data: final data) => + 'SchemaValidationSuccess(data: $data)', + SchemaValidationError(data: final data, errors: final errors) => + 'SchemaValidationError(data: $data, errors: $errors)', + }; + } } class SchemaValidationSuccess extends SchemaValidationResult {