Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 19x | import * as yup from 'yup';
import { isValidDocumentIdForYup } from '../../../src/utils';
import { MESSAGES } from '../../config/messages';
import { LablebDocument } from '../../core/lableb-client/lableb-client.type';
import { IndexingRequestParams } from './indexing.request.type';
interface IndexingSchema extends Omit<IndexingRequestParams, "documents"> {
/**
* the optional key/value in LablebAPIDocument caused issue for yup
* so we define it as an object which only contains "id" field
*/
documents: (Pick<LablebDocument, "id">)[],
}
// @ts-ignore
export const buildIndexingRequestSchema: yup.SchemaOf<IndexingSchema> =
yup.object()
.shape({
indexingAPIKey: yup
.string()
.required(MESSAGES.INDEXING_API_KEY_IS_REQUIRED),
platformName: yup.string().required(MESSAGES.PLATFORM_NAME_IS_REQUIRED),
indexName: yup.string().required(MESSAGES.INDEX_NAME_IS_REQUIRED),
documents: yup
.array()
.required(MESSAGES.DOCUMENTS_IS_REQUIRED)
.min(1, MESSAGES.DOCUMENTS_LENGTH_IS_INVALID)
.of(yup.object().shape({
id: yup.string().required(MESSAGES.DOCUMENT_ID_IS_REQUIRED).test('test-id', MESSAGES.IS_INVALID_DOCUMENT_ID, isValidDocumentIdForYup),
})),
});
|