2018-08-02 13:31:54 +00:00
|
|
|
part of graphql_schema.src.schema;
|
|
|
|
|
|
|
|
class ValidationResult<T> {
|
|
|
|
final bool successful;
|
|
|
|
final T value;
|
|
|
|
final List<String> errors;
|
|
|
|
|
2018-08-03 22:01:36 +00:00
|
|
|
ValidationResult._(this.successful, this.value, this.errors);
|
|
|
|
|
2018-08-02 13:31:54 +00:00
|
|
|
ValidationResult._ok(this.value)
|
|
|
|
: errors = [],
|
|
|
|
successful = true;
|
|
|
|
|
|
|
|
ValidationResult._failure(this.errors)
|
|
|
|
: value = null,
|
|
|
|
successful = false;
|
2018-08-03 22:01:36 +00:00
|
|
|
|
|
|
|
ValidationResult<T> _asFailure() {
|
|
|
|
return new ValidationResult<T>._(false, value, errors);
|
|
|
|
}
|
2018-08-02 13:31:54 +00:00
|
|
|
}
|