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

pelotom / runtypes / 7191708659

13 Dec 2023 06:46AM UTC coverage: 95.97%. First build
7191708659

Pull #339

github

web-flow
Merge 03ef182ec into f0b4cfd74
Pull Request #339: rafactor!: revise project configurations

311 of 329 branches covered (0.0%)

Branch coverage included in aggregate %.

1213 of 1259 new or added lines in 40 files covered. (96.35%)

1213 of 1259 relevant lines covered (96.35%)

1743.45 hits per line

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

93.55
/src/utils-internal/FAILURE.ts
1
import show from "./show.ts"
10✔
2
import typeOf from "./typeOf.ts"
10✔
3
import Failcode from "../result/Failcode.ts"
10✔
4
import Failure from "../result/Failure.ts"
5
import Reflect from "../utils/Reflect.ts"
6

7
const FAILURE = Object.assign(
10✔
8
        (code: Failcode, message: string, details?: Failure.Details): Failure => ({
10✔
9
                success: false,
5,971✔
10
                code,
5,971✔
11
                message,
5,971✔
12
                ...(details ? { details } : {}),
18,612✔
13
        }),
10✔
14
        {
10✔
15
                TYPE_INCORRECT: (self: Reflect, value: unknown) => {
10✔
16
                        const message = `Expected ${
2,930✔
17
                                self.tag === "template" ? `string ${show(self)}` : show(self)
2,930✔
18
                        }, but was ${typeOf(value)}`
2,930✔
19
                        return FAILURE(Failcode.TYPE_INCORRECT, message)
2,930✔
20
                },
10✔
21
                VALUE_INCORRECT: (name: string, expected: unknown, received: unknown) => {
10✔
22
                        return FAILURE(
1,271✔
23
                                Failcode.VALUE_INCORRECT,
1,271✔
24
                                `Expected ${name} ${String(expected)}, but was ${String(received)}`,
1,271✔
25
                        )
26
                },
10✔
27
                KEY_INCORRECT: (self: Reflect, expected: Reflect, value: unknown) => {
10✔
28
                        return FAILURE(
103✔
29
                                Failcode.KEY_INCORRECT,
103✔
30
                                `Expected ${show(self)} key to be ${show(expected)}, but was ${typeOf(value)}`,
103✔
31
                        )
32
                },
10✔
33
                CONTENT_INCORRECT: (self: Reflect, details: Failure.Details) => {
10✔
34
                        const formattedDetails = JSON.stringify(details, null, "\t").replace(/^ *null,\n/gm, "")
709✔
35
                        const message = `Validation failed:\n${formattedDetails}.\nObject should match ${show(self)}`
709✔
36
                        return FAILURE(Failcode.CONTENT_INCORRECT, message, details)
709✔
37
                },
10✔
38
                ARGUMENT_INCORRECT: (message: string) => {
10✔
39
                        return FAILURE(Failcode.ARGUMENT_INCORRECT, message)
14✔
40
                },
10✔
41
                RETURN_INCORRECT: (message: string) => {
10✔
42
                        return FAILURE(Failcode.RETURN_INCORRECT, message)
11✔
43
                },
10✔
44
                CONSTRAINT_FAILED: (self: Reflect, message?: string) => {
10✔
45
                        const info = message ? `: ${message}` : ""
381✔
46
                        return FAILURE(Failcode.CONSTRAINT_FAILED, `Failed constraint check for ${show(self)}${info}`)
381✔
47
                },
10✔
48
                PROPERTY_MISSING: (self: Reflect) => {
10✔
49
                        const message = `Expected ${show(self)}, but was missing`
569✔
50
                        return FAILURE(Failcode.PROPERTY_MISSING, message)
569✔
51
                },
10✔
NEW
52
                PROPERTY_PRESENT: (value: unknown) => {
×
NEW
53
                        const message = `Expected nothing, but was ${typeOf(value)}`
×
NEW
54
                        return FAILURE(Failcode.PROPERTY_PRESENT, message)
×
NEW
55
                },
×
56
                NOTHING_EXPECTED: (value: unknown) => {
10✔
57
                        const message = `Expected nothing, but was ${typeOf(value)}`
63✔
58
                        return FAILURE(Failcode.NOTHING_EXPECTED, message)
63✔
59
                },
63✔
60
        },
10✔
61
)
62

63
export default FAILURE
10✔
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