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

input-output-hk / atala-prism-wallet-sdk-ts / 9416468997

07 Jun 2024 11:46AM UTC coverage: 69.3% (+1.2%) from 68.144%
9416468997

Pull #215

github

web-flow
Merge ff72c3dfc into 78838eaef
Pull Request #215: feat: Backup and Restore

1087 of 1756 branches covered (61.9%)

Branch coverage included in aggregate %.

218 of 264 new or added lines in 29 files covered. (82.58%)

3 existing lines in 2 files now uncovered.

2290 of 3117 relevant lines covered (73.47%)

19.41 hits per line

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

62.5
/src/utils/validation.ts
1
import { Static, TObject } from "@sinclair/typebox";
2
import { Value } from '@sinclair/typebox/value';
3

4
/**
5
 * validateSafe
6
 * Typeguard - check a value matches a schema
7
 * 
8
 * @param json 
9
 * @param schema 
10
 * @returns {boolean}
11
 */
12
export const validateSafe = <T extends TObject>(json: unknown, schema: T): json is Static<T> => {
38✔
13
  const pass = Value.Check(schema, json);
16✔
14
  return pass;
16✔
15
};
16

17
/**
18
 * validate
19
 * Type assertion - assert a value matches a schema
20
 * 
21
 * @param json 
22
 * @param schema 
23
 * @throws Error - list of issues
24
 */
25
export function validate<T extends TObject>(json: unknown, schema: T): asserts json is Static<T> {
26
  if (!validateSafe(json, schema)) {
14!
NEW
27
    const errors = [...Value.Errors(schema, json)].map(x => `${x.path} - ${x.message}`).join(" | ");
×
NEW
28
    throw new Error(errors);
×
29
  }
30
}
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