mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: import fialed due to text field values
This commit is contained in:
parent
8abdb8eaac
commit
bac7d20ad9
24
packages/core/database/src/interfaces/input-interface.ts
Normal file
24
packages/core/database/src/interfaces/input-interface.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* This file is part of the NocoBase (R) project.
|
||||||
|
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||||
|
* Authors: NocoBase Team.
|
||||||
|
*
|
||||||
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||||
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { BaseInterface } from './base-interface';
|
||||||
|
|
||||||
|
export class InputInterface extends BaseInterface {
|
||||||
|
toValue(value) {
|
||||||
|
if (this.validate(value)) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
throw new Error('Invalid value, expected string');
|
||||||
|
}
|
||||||
|
|
||||||
|
validate(value): boolean {
|
||||||
|
return _.isString(value) || _.isNumber(value);
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ import { OneToManyInterface } from './one-to-many-interface';
|
|||||||
import { IntegerInterface } from './integer-interface';
|
import { IntegerInterface } from './integer-interface';
|
||||||
import { NumberInterface } from './number-interface';
|
import { NumberInterface } from './number-interface';
|
||||||
import { JsonInterface } from './json-interface';
|
import { JsonInterface } from './json-interface';
|
||||||
|
import { InputInterface } from './input-interface';
|
||||||
|
|
||||||
const interfaces = {
|
const interfaces = {
|
||||||
integer: IntegerInterface,
|
integer: IntegerInterface,
|
||||||
@ -52,6 +53,7 @@ const interfaces = {
|
|||||||
m2o: ManyToOneInterface,
|
m2o: ManyToOneInterface,
|
||||||
m2m: ManyToManyInterface,
|
m2m: ManyToManyInterface,
|
||||||
time: TimeInterface,
|
time: TimeInterface,
|
||||||
|
input: InputInterface,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function registerInterfaces(db: Database) {
|
export function registerInterfaces(db: Database) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user