mirror of
https://github.com/apple/pkl.git
synced 2026-01-12 06:40:42 +01:00
Use custom annotations to override type validation during JSON to Typed conversion #369
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @avantikasparihar on GitHub (Nov 25, 2025).
Problem Statement
We have a use case where we need to selectively bypass type validation for properties marked with custom annotations during JSON-to-Typed object conversion.
Current Behavior
When using deepToTyped converter to transform JSON data into Pkl Typed objects, all properties undergo strict type validation. For example, if a property is defined as String, the converter will fail if the JSON contains a non-string value.
Desired Behavior
We want to define custom annotations (e.g., @Secret) that, when applied to a property, allow the converter to bypass type validation for that specific property.
Use Case Example
Pkl Schema Definition:
Input JSON:
Please suggest the best approach to achieve this.