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

cartesi / rollups-explorer / 10885484064

02 Sep 2024 12:42PM UTC coverage: 93.408% (-0.4%) from 93.768%
10885484064

Pull #232

github

nevendyulgerov
feat(apps/web): Tweak import validations
Pull Request #232: #229 Add import and export for specifications

1217 of 1450 branches covered (83.93%)

Branch coverage included in aggregate %.

515 of 603 new or added lines in 8 files covered. (85.41%)

3 existing lines in 1 file now uncovered.

13053 of 13827 relevant lines covered (94.4%)

38.51 hits per line

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

89.58
/apps/web/src/components/specification/transfer/validator.ts
1
import { validateSpecificationImport as v1Validator } from "./validators/v1";
1✔
2
import { SpecificationTransfer } from "../types";
1✔
3
import { isFunction } from "ramda-adjunct";
1✔
4

1✔
5
type Validators = Record<
1✔
6
    string,
1✔
7
    (specification: SpecificationTransfer) => Promise<void>
1✔
8
>;
1✔
9

1✔
10
const validators: Validators = {
1✔
11
    "1": v1Validator,
1✔
12
} as const;
1✔
13

1✔
14
export const VALIDATOR_VERSIONS = Object.keys(validators);
1✔
15

1✔
16
export const VALIDATOR_VERSION =
1✔
17
    VALIDATOR_VERSIONS[VALIDATOR_VERSIONS.length - 1];
1✔
18

1✔
19
export const validateSpecification = (specification: SpecificationTransfer) => {
1✔
20
    const specificationVersion = specification.version?.toString();
21✔
21

21✔
22
    return new Promise((resolve, reject) => {
21✔
23
        if (!VALIDATOR_VERSIONS.includes(specificationVersion)) {
21✔
24
            return reject([
1✔
25
                `Invalid 'version' field. Version must be of numeric value and must match one of the following values: ${VALIDATOR_VERSIONS.join(
1✔
26
                    ", ",
1✔
27
                )}.`,
1✔
28
            ]);
1✔
29
        }
1✔
30

20✔
31
        const validator =
20✔
32
            validators[specificationVersion as keyof typeof validators];
20✔
33

20✔
34
        if (!isFunction(validator)) {
21!
NEW
35
            return reject([
×
NEW
36
                "Missing validator for this specification version. Please contact support for further assistance.",
×
NEW
37
            ]);
×
NEW
38
        }
✔
39

20✔
40
        validator(specification).then(resolve).catch(reject);
20✔
41
    });
21✔
42
};
21✔
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