Allow passing custom TypeInfo to validate

This commit is contained in:
Vladimir Razuvaev 2017-07-04 16:19:16 +07:00
parent a53b798f29
commit 189877c173

View File

@ -122,9 +122,9 @@ class DocumentValidator
self::$rules[$name] = $rule; self::$rules[$name] = $rule;
} }
public static function validate(Schema $schema, DocumentNode $ast, array $rules = null) public static function validate(Schema $schema, DocumentNode $ast, array $rules = null, TypeInfo $typeInfo = null)
{ {
$typeInfo = new TypeInfo($schema); $typeInfo = $typeInfo ?: new TypeInfo($schema);
$errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules ?: static::allRules()); $errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules ?: static::allRules());
return $errors; return $errors;
} }