UNPKG

@boomerang-io/carbon-addons-boomerang-react

Version:
23 lines (20 loc) 618 B
import { object } from 'yup'; /* IBM Confidential 694970X, 69497O0 © Copyright IBM Corp. 2022, 2024 */ const CUSTOM_VALIDATORS = {}; function addCustomValidator(name, validator, binding = false) { if (binding !== false) { validator = validator.bind(binding); } CUSTOM_VALIDATORS[name] = validator; } function getCustomValidator(name) { return CUSTOM_VALIDATORS[name]; } // Handle the case when we have an array of objects // but the previous instance of yup.shape is the yup.array addCustomValidator("yup.shape", object().shape, object()); export { addCustomValidator, getCustomValidator };