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

input-output-hk / atala-prism-building-blocks / 8699251619

16 Apr 2024 02:54AM UTC coverage: 31.165% (+0.4%) from 30.781%
8699251619

Pull #969

CryptoKnightIOG
ATL-6782: Aud check

Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Pull Request #969: feat: VC Verification Audiance check

0 of 46 new or added lines in 4 files covered. (0.0%)

486 existing lines in 113 files now uncovered.

4512 of 14478 relevant lines covered (31.16%)

0.31 hits per line

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

62.5
/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/schema/validator/SchemaSerDes.scala
1
package io.iohk.atala.pollux.core.model.schema.validator
2

3
import com.networknt.schema.JsonSchema
4
import io.iohk.atala.pollux.core.model.schema.validator.JsonSchemaError.*
5
import zio.json.*
6
import zio.json.ast.Json
7
import zio.json.ast.Json.*
8
import zio.{IO, ZIO}
9

10
class SchemaSerDes[S](jsonSchemaSchemaStr: String) {
11

1✔
12
  def initialiseJsonSchema: IO[JsonSchemaError, JsonSchema] =
1✔
13
    JsonSchemaUtils.jsonSchema(jsonSchemaSchemaStr)
14

1✔
15
  def serializeToJsonString(instance: S)(using encoder: JsonEncoder[S]): String = {
1✔
16
    instance.toJson
17
  }
18

1✔
19
  def serialize(instance: S)(using encoder: JsonEncoder[S]): Either[String, Json] = {
1✔
20
    instance.toJsonAST
21
  }
22

×
23
  def deserialize(
24
      schema: zio.json.ast.Json
25
  )(using decoder: JsonDecoder[S]): IO[JsonSchemaError, S] = {
×
26
    deserialize(schema.toString())
27
  }
28

1✔
29
  def deserialize(
30
      jsonString: String
31
  )(using decoder: JsonDecoder[S]): IO[JsonSchemaError, S] = {
1✔
UNCOV
32
    for {
×
33
      _ <- validate(jsonString)
1✔
34
      anoncredSchema <-
×
35
        ZIO
×
36
          .fromEither(decoder.decodeJson(jsonString))
37
          .mapError(JsonSchemaError.JsonSchemaParsingError.apply)
38
    } yield anoncredSchema
39
  }
40

1✔
41
  def deserializeAsJson(jsonString: String): IO[JsonSchemaError, Json] = {
1✔
42
    for {
1✔
43
      _ <- validate(jsonString)
1✔
44
      json <-
×
45
        ZIO
×
46
          .fromEither(jsonString.fromJson[Json])
47
          .mapError(JsonSchemaError.JsonSchemaParsingError.apply)
48
    } yield json
49
  }
50

1✔
51
  def validate(jsonString: String): IO[JsonSchemaError, Unit] = {
1✔
UNCOV
52
    for {
×
53
      jsonSchemaSchema <- JsonSchemaUtils.jsonSchema(jsonSchemaSchemaStr)
UNCOV
54
      schemaValidator = JsonSchemaValidatorImpl(jsonSchemaSchema)
×
55
      result <- schemaValidator.validate(jsonString)
56
    } yield result
57
  }
58

59
}
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

© 2025 Coveralls, Inc