Skip to content

Replace applySchemaDefaults workaround after adapt-schemas v3.x migration #184

@taylortom

Description

@taylortom

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.jsapplySchemaDefaults() method (marked with a TODO comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions