Skip to content

Add backwards compatibility for optional fields in Documents #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

patpaev
Copy link
Collaborator

@patpaev patpaev commented Mar 22, 2024

When a Document field is optional, we no longer validate that it's necessary in the fields or target_signature of a DocumentTemplate to be installed

Also changing the Installed DocumentTemplate has additional fields that are not used in any target Document error to a warning, so that a code rollback is still possible after an optional field is added to a Document

@@ -109,5 +111,8 @@ data class BarberSignature(
)

fun Document.getBarberSignature() = BarberSignature(this::class.asFieldsMap())

fun KClass<*>.getMinimumRequiredSignatureToSatisfy() = BarberSignature(asFieldsMap(includeNullableFields = false))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling asFieldsMap doesn't need this::class.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, for Document.getBarberSignature() above, we're calling this::class to get the KClass, which is how we can access its memberProperties

@patpaev patpaev merged commit 97b01fc into master Apr 3, 2024
4 checks passed
@patpaev patpaev deleted the patrickp.optional-docment-fields-backwards-compatible branch April 3, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants