@sprucelabs/schema
Version:
Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓
26 lines (25 loc) • 885 B
JavaScript
import AbstractField from './AbstractField.js';
class RawField extends AbstractField {
static generateTemplateDetails(options) {
const { definition, language } = options;
const { isArray } = definition;
const { options: fieldOptions } = definition;
const { valueType } = fieldOptions;
const arrayNotation = isArray ? '[]' : '';
let resolvedType = valueType;
if (language === 'go') {
const goType = valueType === 'Record<string, any>'
? 'map[string]interface{}'
: 'interface{}';
resolvedType = `${arrayNotation}${goType}`;
}
else {
resolvedType = `(${valueType})${arrayNotation}`;
}
return {
valueType: resolvedType,
};
}
}
RawField.description = 'Set an interface directly.';
export default RawField;