@yuneta/gobj-js 7.25.2 → 7.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3608,10 +3608,13 @@
3608
3608
  }
3609
3609
  /************************************************************
3610
3610
  * As the C kw_get_bool(): a boolean found is the answer, and
3611
- * anything else gives the default back -- unless KW_WILD_NUMBER
3612
- * asks to read a number (0 is false), a string ("true"/"false"
3613
- * in any case, else its integer) or null (false). Before gobj-js
3614
- * 7.25.2 the value went through Boolean(), so "false" was TRUE.
3611
+ * anything else gives the default back, LOGGED ("path MUST BE a
3612
+ * json boolean", required or not) -- unless KW_WILD_NUMBER asks
3613
+ * to read a number (0 is false), a string ("true"/"false" in any
3614
+ * case, else its integer) or null (false); a list or a dict is
3615
+ * then false, logged too. Before gobj-js 7.25.2 the value went
3616
+ * through Boolean(), so "false" was TRUE; before 7.25.3 a value
3617
+ * of the wrong type gave the default back in silence.
3615
3618
  ************************************************************/
3616
3619
  function kw_get_bool(gobj, kw, path, default_value, flag) {
3617
3620
  if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
@@ -3639,11 +3642,13 @@
3639
3642
  else if (b.toLowerCase() === "false") value = false;
3640
3643
  else value = (parseInt(b) || 0) !== 0;
3641
3644
  } else if (wild && b === null) value = false;
3642
- else {
3643
- if (required) {
3644
- log_error(`${gobj_short_name(gobj)}: path value MUST BE a boolean: ${path}`);
3645
- trace_msg(kw);
3646
- }
3645
+ else if (wild) {
3646
+ log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a simple json element: '${path}'`);
3647
+ trace_json(kw);
3648
+ return false;
3649
+ } else {
3650
+ log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json boolean: '${path}'`);
3651
+ trace_json(kw);
3647
3652
  return Boolean(default_value);
3648
3653
  }
3649
3654
  if (extract) kw_delete(gobj, kw, path);