Skip to content

Commit

Permalink
validations
Browse files Browse the repository at this point in the history
  • Loading branch information
pshirshov committed Nov 8, 2023
1 parent da39e5d commit 0b011c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,15 @@ object BaboonIssue {
}
}

case class BadFieldNames(e: Typedef.Dto, bad: Seq[String], meta: RawNodeMeta)
extends VerificationIssue {
override def toString: String = {
s"""
|${extractLocation(meta)}
|Bad field names: ${e.id.toString} / ${bad}
|""".stripMargin
}
}
case class EmptyEnumDef(e: Typedef.Enum, meta: RawNodeMeta)
extends VerificationIssue {
override def toString: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,14 @@ object BaboonValidator {
Right(())
case u: DomainMember.User =>
u.defn match {
case _: Typedef.Dto =>
Right(())
case d: Typedef.Dto =>
for {
badFields <- Right(d.fields.map(_.name.name.toLowerCase).filter(_ == d.id.name.name.toLowerCase))
_ <- Either.ifThenFail(badFields.nonEmpty)(
NEList(BaboonIssue.BadFieldNames(d, badFields, u.meta))
)
} yield {
}
case e: Typedef.Enum =>
for {
_ <- Either.ifThenFail(e.members.isEmpty)(
Expand Down

0 comments on commit 0b011c9

Please sign in to comment.