MCPcopy Create free account
hub / github.com/apitable/apitable / checkRecordsValues

Method checkRecordsValues

packages/widget-sdk/src/model/datasheet.ts:115–136  ·  view source on GitHub ↗
(records: { [key: string]: any }[])

Source from the content-addressed store, hash-verified

113 }
114
115 private checkRecordsValues(records: { [key: string]: any }[]) {
116 const state = this.wCtx.widgetStore.getState() as any as IReduxState;
117 const fieldDataMap = Selectors.getFieldMap(state, this.datasheetId)!;
118
119 records.forEach(valuesMap => {
120 Object.entries(valuesMap).forEach(([fieldId, cellValue]) => {
121 const fieldData = fieldDataMap[fieldId];
122 if (!fieldData) {
123 throw new Error(`FieldId: ${fieldId} is not exist in datasheet`);
124 }
125
126 const coreField = CoreField.bindModel(fieldDataMap[fieldId]!, state);
127 if (!coreField.recordEditable(this.datasheetId)) {
128 throw new Error(`FieldId: ${fieldId} is not editable`);
129 }
130
131 if (coreField.validateCellValue(cellValue).error) {
132 throw new Error(`CellValue: ${cellValue} is not validate for field ${fieldId}(${fieldData.name})`);
133 }
134 });
135 });
136 }
137
138 private transformRecordValues(records: { [key: string]: any }[]): { [key: string]: any }[] {
139 const state = this.wCtx.widgetStore.getState() as any as IReduxState;

Callers 2

addRecordsMethod · 0.95
setRecordsMethod · 0.95

Calls 5

getFieldMapMethod · 0.80
forEachMethod · 0.45
bindModelMethod · 0.45
recordEditableMethod · 0.45
validateCellValueMethod · 0.45

Tested by

no test coverage detected