(schema: CellSchema | ValueSchema)
| 365 | ): boolean => objValidate(valuesSchema, validateCellOrValueSchema); |
| 366 | |
| 367 | const validateCellOrValueSchema = (schema: CellSchema | ValueSchema) => { |
| 368 | if ( |
| 369 | !objValidate(schema, (_child, id: Id) => |
| 370 | arrayHas([TYPE, DEFAULT, ALLOW_NULL], id), |
| 371 | ) |
| 372 | ) { |
| 373 | return false; |
| 374 | } |
| 375 | const type = schema[TYPE]; |
| 376 | if (!isTypeStringOrBoolean(type) && type != NUMBER && !isJsonType(type)) { |
| 377 | return false; |
| 378 | } |
| 379 | const defaultValue = schema[DEFAULT]; |
| 380 | if (isNull(defaultValue) && !schema[ALLOW_NULL]) { |
| 381 | return false; |
| 382 | } |
| 383 | if (!isNull(defaultValue)) { |
| 384 | if (getCellOrValueType(defaultValue) != type) { |
| 385 | objDel(schema as any, DEFAULT); |
| 386 | } else { |
| 387 | (schema as any)[DEFAULT] = encodeIfJson(defaultValue as Cell); |
| 388 | } |
| 389 | } |
| 390 | return true; |
| 391 | }; |
| 392 | |
| 393 | const validateContent = isArray; |
| 394 |
nothing calls this directly
no test coverage detected
searching dependent graphs…