Check if a property is nullable #1218
                  
                    
                      discount-elf
                    
                  
                
                  started this conversation in
                General
              
            Replies: 1 comment 1 reply
-
| 
         Yup! Here's how you'd do that: import "pkl:reflect"
class Foo {
  required: String
  nullable: String?
}
propRequired = reflect.Class(Foo).properties["required"].type is reflect.NullableType
propNullable = reflect.Class(Foo).properties["nullable"].type is reflect.NullableTypeResult: propRequired = false
propNullable = true | 
  
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there simple way (via reflection or otherwise) to check if a property is nullable?
.defaultValuereturning null sort of works but is there a solid solution?Beta Was this translation helpful? Give feedback.
All reactions