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:
class DatabaseConfig {
host: String
port: Int
@Secret
password: String // Should accept any JSON value type, not just strings
}
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?
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](https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped/current/deepToTyped/index.html) 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.
1. What would be the most idiomatic way to handle annotation-based type validation bypassing in Pkl?
2. Are there existing patterns or mechanisms in Pkl that we should leverage for this use case?
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.