MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / normalizeControlValue

Function normalizeControlValue

botasaurus-controls/src/index.ts:393–410  ·  view source on GitHub ↗

* Helper function to normalize control values - extracts values from object formats * and parses JSON strings for jsonTextArea controls * @param control - The control object * @param value - The value to normalize * @returns The normalized value

(control: any, value: any)

Source from the content-addressed store, hash-verified

391 * @returns The normalized value
392 */
393function normalizeControlValue(control: any, value: any) {
394 // @ts-ignore
395 if (control.searchMethod && control.type === 'select') {
396 return extractValueFromObject(value)
397 }
398 // @ts-ignore
399 else if (control.searchMethod && control.type === 'multiSelect') {
400 if (Array.isArray(value)) {
401 return value.map(extractValueFromObject)
402 }
403 }
404 // Parse JSON string to object for jsonTextArea
405 else if (control.type === 'jsonTextArea') {
406 const { parsed } = parseJSON(value)
407 return parsed
408 }
409 return value
410}
411
412const parseBoolean = (value:any) => {
413 if (typeof value === 'string') {

Callers 1

getParsedControlDataMethod · 0.85

Calls 2

extractValueFromObjectFunction · 0.85
parseJSONFunction · 0.85

Tested by

no test coverage detected