2018-08-02 13:31:54 +00:00
|
|
|
part of graphql_schema.src.schema;
|
|
|
|
|
2018-08-05 02:38:11 +00:00
|
|
|
/// Represents the result of asserting an input [value] against a [GraphQLType].
|
|
|
|
class ValidationResult<Value> {
|
|
|
|
/// `true` if there were no errors during validation.
|
2018-08-02 13:31:54 +00:00
|
|
|
final bool successful;
|
2018-08-05 02:38:11 +00:00
|
|
|
|
|
|
|
/// The input value passed to whatever caller invoked validation.
|
|
|
|
final Value value;
|
|
|
|
|
|
|
|
/// A list of errors that caused validation to fail.
|
2018-08-02 13:31:54 +00:00
|
|
|
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
|
|
|
|
2018-08-04 19:18:53 +00:00
|
|
|
// ValidationResult<T> _asFailure() {
|
|
|
|
// return new ValidationResult<T>._(false, value, errors);
|
|
|
|
// }
|
|
|
|
}
|