UNPKG

@lableb/javascript-sdk

Version:

Lableb cloud search client for javascript

29 lines (23 loc) 878 B
import * as yup from 'yup'; import { MESSAGES } from '../config/messages'; import { isValidHttpMethod } from '../utils'; export const lablebHttpClientSchema = yup.object().shape({ method: yup .string() .required() .test('test-http-method', MESSAGES.WRONG_HTTP_METHOD, isValidHttpMethod), url: yup.string().required(), body: yup.mixed().when('method', { is: (value: string) => value == 'GET' || value == 'DELETE', then: yup.mixed() .test('test-not-required', MESSAGES.BODY_IS_NOT_ALLOWED_FOR_GET_OR_DELETE, (value: any) => { if (value) return false; return true; }), otherwise: yup.mixed().required(MESSAGES.BODY_IS_REQUIRED), }), params: yup.object().optional(), headers: yup.object().optional(), });