• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

snowplow / iglu-scala-client / 18825838924

27 Oct 2025 12:13AM UTC coverage: 81.297% (-0.7%) from 81.96%
18825838924

Pull #265

github

web-flow
Merge 2bfa16e49 into ee4d9c6d7
Pull Request #265: Upgrade json-schema-validator from 1.0.76 to 1.5.8

16 of 17 new or added lines in 1 file covered. (94.12%)

11 existing lines in 6 files now uncovered.

539 of 663 relevant lines covered (81.3%)

0.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.75
/modules/data/src/main/scala/com.snowplowanalytics.iglu/client/validator/ValidatorError.scala
1
/*
2
 * Copyright (c) 2014-2023 Snowplow Analytics Ltd. All rights reserved.
3
 *
4
 * This program is licensed to you under the Apache License Version 2.0,
5
 * and you may not use this file except in compliance with the Apache License Version 2.0.
6
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
 *
8
 * Unless required by applicable law or agreed to in writing,
9
 * software distributed under the Apache License Version 2.0 is distributed on an
10
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
 */
13
package com.snowplowanalytics.iglu.client
14
package validator
15

16
import io.circe._
17
import io.circe.syntax._
18

19
import cats.data.NonEmptyList
20

21
/** ADT describing issues that can be discovered by Validator */
22
sealed trait ValidatorError extends Product with Serializable {
23
  def toClientError(supersededBy: Option[String]): ClientError =
24
    ClientError.ValidationError(this, supersededBy)
1✔
25
}
26

27
object ValidatorError {
28

29
  /** Primary error, indicating there are invalid properties in JSON instance */
30
  final case class InvalidData(messages: NonEmptyList[ValidatorReport]) extends ValidatorError
31

32
  /** Unlike ResolverError.InvalidSchema, this one is more strict */
33
  final case class InvalidSchema(issues: NonEmptyList[SchemaIssue]) extends ValidatorError
34

35
  /**
36
   * Short human-readable description of problem discovered in JSON Schema
37
   * @param path JSON Path to problematic schema property
38
   * @param message human-readable error message
39
   */
40
  final case class SchemaIssue(path: String, message: String)
41

42
  private[client] def schemaIssue(issue: Throwable): ValidatorError.InvalidSchema =
UNCOV
43
    InvalidSchema(NonEmptyList.of(SchemaIssue("$", issue.getMessage)))
×
44

45
  implicit val validatorErrorJsonEncoder: Encoder.AsObject[ValidatorError] =
46
    Encoder.AsObject.instance {
1✔
47
      case InvalidData(messages) => JsonObject.fromMap(Map("dataReports" -> messages.asJson))
1✔
48
      case InvalidSchema(issues) => JsonObject.fromMap(Map("schemaIssues" -> issues.asJson))
×
49
    }
50

51
  implicit val validatorErrorJsonDecoder: Decoder[ValidatorError] =
52
    Decoder.instance { cursor =>
1✔
53
      for {
54
        validatorError <- cursor.downField("dataReports").focus match {
55
          case Some(dataReports) =>
56
            dataReports.as[NonEmptyList[ValidatorReport]].map(reps => InvalidData(reps))
1✔
57
          case None =>
58
            cursor
59
              .downField("schemaIssues")
×
60
              .as[NonEmptyList[SchemaIssue]]
×
61
              .map(reps => InvalidSchema(reps))
×
62
        }
63
      } yield validatorError
64
    }
65

66
  implicit val schemaIssueCirceJsonEncoder: Encoder[SchemaIssue] =
67
    Encoder.instance { issue =>
1✔
68
      Json.obj("path" := issue.path, "message" := issue.message)
×
69
    }
70

71
  implicit val schemaIssueCirceJsonDecoder: Decoder[SchemaIssue] =
72
    Decoder.instance { cursor =>
1✔
73
      for {
74
        path    <- cursor.downField("path").as[String]
×
75
        message <- cursor.downField("message").as[String]
×
76
      } yield SchemaIssue(path, message)
×
77
    }
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc