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

Class StringType

packages/repository/src/types/string.ts:13–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 * String type
12 */
13export class StringType implements Type<string> {
14 readonly name = 'string';
15
16 isInstance(value: any): boolean {
17 return value == null || typeof value === 'string';
18 }
19
20 isCoercible(value: any): boolean {
21 return true;
22 }
23
24 defaultValue(): string {
25 return '';
26 }
27
28 coerce(value: any): string {
29 if (value == null) return value;
30 if (typeof value.toJSON === 'function') {
31 value = value.toJSON();
32 }
33 if (typeof value === 'object') {
34 return JSON.stringify(value);
35 }
36 return String(value);
37 }
38
39 serialize(value: string | null | undefined) {
40 return value;
41 }
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected