@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.
@@ -3604,10 +3604,13 @@ function kw_delete(gobj, kw, path) {
3604
3604
  }
3605
3605
  /************************************************************
3606
3606
  * As the C kw_get_bool(): a boolean found is the answer, and
3607
- * anything else gives the default back -- unless KW_WILD_NUMBER
3608
- * asks to read a number (0 is false), a string ("true"/"false"
3609
- * in any case, else its integer) or null (false). Before gobj-js
3610
- * 7.25.2 the value went through Boolean(), so "false" was TRUE.
3607
+ * anything else gives the default back, LOGGED ("path MUST BE a
3608
+ * json boolean", required or not) -- unless KW_WILD_NUMBER asks
3609
+ * to read a number (0 is false), a string ("true"/"false" in any
3610
+ * case, else its integer) or null (false); a list or a dict is
3611
+ * then false, logged too. Before gobj-js 7.25.2 the value went
3612
+ * through Boolean(), so "false" was TRUE; before 7.25.3 a value
3613
+ * of the wrong type gave the default back in silence.
3611
3614
  ************************************************************/
3612
3615
  function kw_get_bool(gobj, kw, path, default_value, flag) {
3613
3616
  if (gobj && !is_gobj(gobj)) log_error(`GObj bad instanceof`);
@@ -3635,11 +3638,13 @@ function kw_get_bool(gobj, kw, path, default_value, flag) {
3635
3638
  else if (b.toLowerCase() === "false") value = false;
3636
3639
  else value = (parseInt(b) || 0) !== 0;
3637
3640
  } else if (wild && b === null) value = false;
3638
- else {
3639
- if (required) {
3640
- log_error(`${gobj_short_name(gobj)}: path value MUST BE a boolean: ${path}`);
3641
- trace_msg(kw);
3642
- }
3641
+ else if (wild) {
3642
+ log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a simple json element: '${path}'`);
3643
+ trace_json(kw);
3644
+ return false;
3645
+ } else {
3646
+ log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}path MUST BE a json boolean: '${path}'`);
3647
+ trace_json(kw);
3643
3648
  return Boolean(default_value);
3644
3649
  }
3645
3650
  if (extract) kw_delete(gobj, kw, path);