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 | 19x | import * as yup from 'yup';
import { MESSAGES } from '../../config/messages';
import { isValidDocumentIdForYup, isValidIntegerForYup } from '../../utils';
import { baseRequestSchema } from '../main/main.request.schema';
import { RecommendRequestParams } from './recommend.request.type';
// @ts-ignore
export const buildRecommendRequestSchema: yup.SchemaOf<RecommendRequestParams> =
baseRequestSchema.concat(
yup.object()
.shape({
APIKey: yup
.string()
.required(MESSAGES.API_KEY_IS_REQUIRED),
id: yup.string()
.test('test-id', MESSAGES.IS_INVALID_DOCUMENT_ID, isValidDocumentIdForYup)
.required(MESSAGES.DOCUMENT_ID_IS_REQUIRED),
title: yup.string().optional(),
url: yup.string().url(MESSAGES.URL_IS_NOT_VALID).optional(),
recommendHandler: yup.string().optional(),
sort: yup.string().optional(),
limit: yup.number().optional().test('test-integer', MESSAGES.LIMIT_IS_NOT_INTEGER, isValidIntegerForYup),
})
);
|