-
Notifications
You must be signed in to change notification settings - Fork 344
Open
Description
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:
class DatabaseConfig {
host: String
port: Int
@Secret
password: String // Should accept any JSON value type, not just strings
}
Input JSON:
{
"host": "localhost",
"port": 5432,
"password": {
"$secret": {
"type": "",
"name": "db_password"
}
}
}
Please suggest the best approach to achieve this.
- What would be the most idiomatic way to handle annotation-based type validation bypassing in Pkl?
- Are there existing patterns or mechanisms in Pkl that we should leverage for this use case?
Metadata
Metadata
Assignees
Labels
No labels