Summary
applySchemaDefaults() in AdaptFrameworkBuild.js currently uses a try/catch workaround to apply schema defaults via schema.validate(), catching errors and extracting the defaulted data from the error object:
const validateWithDefaults = (schema, data) => {
try {
return schema.validate(data, { useDefaults: true, ignoreRequired: true })
} catch (e) {
return e.data.data
}
}
Once the AAT is migrated to adapt-schemas v3.x (cgkineo/adapt-schemas#31), this should be replaced with:
schema.validate(data, { useDefaults: true, ignoreErrors: true })
Location
lib/AdaptFrameworkBuild.js — applySchemaDefaults() method (marked with a TODO comment)