remix-validated-form
Version:
Form component and utils for easy form validation in remix
10 lines (9 loc) • 353 B
JavaScript
export const getCheckboxChecked = (checkboxValue = "on", newValue) => {
if (Array.isArray(newValue))
return newValue.some((val) => val === true || val === checkboxValue);
if (typeof newValue === "boolean")
return newValue;
if (typeof newValue === "string")
return newValue === checkboxValue;
return undefined;
};