platform/packages/graphql/graphql_schema/lib/src/validation_result.dart
Tobe O 4e69153e3e Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca'
git-subtree-dir: packages/graphql
git-subtree-mainline: ac29392d7f
git-subtree-split: 33e2f86ba7
2020-02-15 18:22:07 -05:00

28 lines
757 B
Dart

part of graphql_schema.src.schema;
/// Represents the result of asserting an input [value] against a [GraphQLType].
class ValidationResult<Value> {
/// `true` if there were no errors during validation.
final bool successful;
/// The input value passed to whatever caller invoked validation.
final Value value;
/// A list of errors that caused validation to fail.
final List<String> errors;
ValidationResult._(this.successful, this.value, this.errors);
ValidationResult._ok(this.value)
: errors = [],
successful = true;
ValidationResult._failure(this.errors)
: value = null,
successful = false;
// ValidationResult<T> _asFailure() {
// return new ValidationResult<T>._(false, value, errors);
// }
}