UNPKG

1.1 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. and LoopBack contributors 2017,2019. All Rights Reserved.
3// Node module: @loopback/repository
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.StringType = void 0;
8/* eslint-disable @typescript-eslint/no-explicit-any */
9/**
10 * String type
11 */
12class StringType {
13 constructor() {
14 this.name = 'string';
15 }
16 isInstance(value) {
17 return value == null || typeof value === 'string';
18 }
19 isCoercible(value) {
20 return true;
21 }
22 defaultValue() {
23 return '';
24 }
25 coerce(value) {
26 if (value == null)
27 return value;
28 if (typeof value.toJSON === 'function') {
29 value = value.toJSON();
30 }
31 if (typeof value === 'object') {
32 return JSON.stringify(value);
33 }
34 return String(value);
35 }
36 serialize(value) {
37 return value;
38 }
39}
40exports.StringType = StringType;
41//# sourceMappingURL=string.js.map
\No newline at end of file