Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasPfeifer committed Feb 28, 2020
1 parent e633680 commit fccd277
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/src/main/scala/caliban/validation/Validator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ object Validator {
for {
_ <- doesNotStartWithUnderscore(field.name, "field", "Interface")
_ <- onlyOutputType(field.`type`())
_ <- IO.foreach(field.args){ validateInterfaceArgument }
_ <- IO.foreach(field.args)(validateInterfaceArgument)
} yield ()
)

Expand All @@ -592,7 +592,7 @@ object Validator {
}
}

private def onlyInputType(`type`: __Type): IO[ValidationError, Unit] = {
private def onlyInputType(`type`: __Type): IO[ValidationError, Unit] = {
// https://spec.graphql.org/June2018/#IsInputType()
def isInputType(t: __Type): Either[__Type, Unit] = {
import __TypeKind._
Expand Down Expand Up @@ -632,11 +632,13 @@ object Validator {
}
}

private def noDuplicateFieldName(fields: List[__Field]) = noDuplicateName[__Field](fields, _.name)
private def noDuplicateFieldName(fields: List[__Field]) =
noDuplicateName[__Field](fields, _.name)

private def noDuplicateInputValueName(inputValues: List[__InputValue]) = noDuplicateName[__InputValue](inputValues, _.name)
private def noDuplicateInputValueName(inputValues: List[__InputValue]) =
noDuplicateName[__InputValue](inputValues, _.name)

private def noDuplicateName[T](listOfNamed: List[T], nameExtractor: T => String): IO[ValidationError, Unit] = {
private def noDuplicateName[T](listOfNamed: List[T], nameExtractor: T => String): IO[ValidationError, Unit] =
listOfNamed
.groupBy(nameExtractor(_))
.collectFirst { case (_, f :: _ :: _) => f }
Expand All @@ -646,16 +648,14 @@ object Validator {
"The input field must have a unique name within that Input Object type; no two input fields may share the same name"
)
)
}

private def doesNotStartWithUnderscore(name: String, typeName: String, inType: String): IO[ValidationError, Unit] = {
private def doesNotStartWithUnderscore(name: String, typeName: String, inType: String): IO[ValidationError, Unit] =
IO.when(name.startsWith("__"))(
failValidation(
s"A $typeName in $inType can't start with '__': $name",
s"""The $typeName must not have a name which begins with the characters {"__"} (two underscores)"""
)
)
}

case class Context(
document: Document,
Expand Down

0 comments on commit fccd277

Please sign in to comment.