UNPKG

@nish1896/rhf-mui-components

Version:

A suite of 20+ production-ready react-hook-form components built with material-ui. Fully typed, tree-shakable, and optimized for enterprise-grade forms.

13 lines (12 loc) 602 B
import { generateLabelValueErrMsg } from "./errors.js"; //#region src/utils/array.ts function isPrimitiveArray(options) { return options.every((opt) => typeof opt === "string" || typeof opt === "number"); } function validateArray(formElementName, options, labelKey, valueKey) { if (process.env.NODE_ENV === "production") return; if (!Array.isArray(options)) throw new Error(`The "options" prop of ${formElementName} must be an array.`); if (!isPrimitiveArray(options) && (!labelKey || !valueKey)) throw new Error(generateLabelValueErrMsg(formElementName)); } //#endregion export { validateArray };