UNPKG

@lableb/javascript-sdk

Version:

Lableb cloud search client for javascript

30 lines (20 loc) 909 B
import * as yup from 'yup'; import { MESSAGES } from '../../config/messages'; import { isValidIntegerForYup } from '../../utils'; import { baseRequestSchema } from '../main/main.request.schema'; import { AutocompleteRequestParams } from './autocomplete.request.type'; // @ts-ignore export const buildAutocompleteRequestSchema: yup.SchemaOf<AutocompleteRequestParams> = baseRequestSchema.concat( yup.object() .shape({ APIKey: yup .string() .required(MESSAGES.API_KEY_IS_REQUIRED), query: yup.string().required(MESSAGES.QUERY_IS_REQUIRED), autocompleteHandler: yup.string().optional(), sort: yup.string().optional(), limit: yup.number().optional().test('test-integer', MESSAGES.LIMIT_IS_NOT_INTEGER, isValidIntegerForYup), } ) );