readBooleans.cjs 337 B

123456789101112
  1. 'use strict';
  2. const readBooleans = (fields, listOfBooleans) => {
  3. // html forms do not send off at all
  4. const fieldsWithBooleans = { ...fields };
  5. listOfBooleans.forEach((key) => {
  6. fieldsWithBooleans[key] = fields[key] === `on` || fields[key] === true;
  7. });
  8. return fieldsWithBooleans;
  9. };
  10. exports.readBooleans = readBooleans;