MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / coerce

Method coerce

packages/repository/src/types/union.ts:31–46  ·  view source on GitHub ↗
(value: any)

Source from the content-addressed store, hash-verified

29 }
30
31 coerce(value: any) {
32 // First find instances
33 for (const type of this.itemTypes) {
34 if (type.isInstance(value)) {
35 return type.coerce(value);
36 }
37 }
38 // Try coercible
39 for (const type of this.itemTypes) {
40 if (type.isCoercible(value)) {
41 return type.coerce(value);
42 }
43 }
44 const msg = util.format('Invalid %s: %j', this.name, value);
45 throw new TypeError(msg);
46 }
47
48 serialize(value: any) {
49 for (const type of this.itemTypes) {

Callers

nothing calls this directly

Calls 3

isInstanceMethod · 0.65
coerceMethod · 0.65
isCoercibleMethod · 0.65

Tested by

no test coverage detected