isMarkedNullable is a Kotlin reflection property on a reflected type. It reports whether that type is declared nullable, helping deserialization distinguish an allowed null from a missing required value. section 12.2.5
Checking required constructor parameters
private fun ensureAllParametersPresent(arguments: Map<KParameter, Any?>) { for (param in constructor.parameters) { if (arguments[param] == null && !param.isOptional && !param.type.isMarkedNullable) { throw JKidException("Missing value for parameter ${param.name}") } } } The check allows a missing optional parameter to use its default value, and allows null for a nullable parameter. Only a missing, non-optional, non-nullable parameter causes an exception. section 12.2.5
Listing 12.14 Validating that required parameters are provided
private fun ensureAllParametersPresent(arguments: Map<KParameter, Any?>) {
for (param in constructor.parameters) {
if (arguments[param] == null &&
!param.isOptional && !param.type.isMarkedNullable) {
throw JKidException("Missing value for parameter ${param.name}")
}
}
}
Inspect the complete validation function, including the relationship between arguments, optional parameters, nullable types, and deserialization errors. section 12.2.5
