fix: import fialed due to text field values

This commit is contained in:
aaaaaajie 2025-04-18 00:46:11 +08:00
parent 8abdb8eaac
commit bac7d20ad9
2 changed files with 26 additions and 0 deletions

View 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);
}
}

View File

@ -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) {