Autoform suddenly stopped handling booleans

I have an old system, predating the dinosaurs and even daylight, that was running Meteor 1.x until I upgraded it up to 2.15 last week. I had to remove/update a lot of components but now it is running well. Apart from Booleans in Autoform.

The booleans display as they should, but they handle as if they are strings so Autoforms validator complains, saying it has to be a value there, regardless if it is checked or not.

Versions for what I see is the stuff related are the same as when sys was running 1.x:

aldeed:autoform@5.8.1
aldeed:collection2@2.10.0
aldeed:collection2-core@1.2.0
aldeed:schema-deny@1.1.0
aldeed:schema-index@1.1.1
aldeed:simple-schema@1.5.4
aldeed:template-extension@4.1.0

Anyone has a clue why this is happening?

Thanks

I ran into the same issue after migrating to version 2.16. Did you ever come up with a solution @ralof?

do you have the output log for better undestand?
that pkgs is based on simpl-schema, so with the output error we cant start a debug

There is an old issue in meteor-autoform (#216) that describes identical behavior; the suggested solution was to extend AutoForm.inputValueHandlers to convert the strings "true"/"false" into booleans.

A simpler alternative is to enable automatic cleaning in SimpleSchema:

SimpleSchema.setDefaultOptions({
  clean: { convertStringsToBoolean: true },
});

Or, when defining your schema, you can use autoValue to coerce boolean fields. For example:

isActive: {
  type: Boolean,
  autoValue() {
    const val = this.valueOf();
    if (typeof val === 'string') return val === 'true';
    return val;
  }
}

If you’re using AutoForm with type="hidden", you can add a hiddenInputValueHandler to convert "true"/"false" strings into booleans.

let me know if it works