UNPKG

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

Version:
26 lines (22 loc) 701 B
'use strict'; var yup = require('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", yup.object().shape, yup.object()); exports.addCustomValidator = addCustomValidator; exports.getCustomValidator = getCustomValidator;