Siddhartha Juluru
08/13/2022, 2:23 AM@Entity
class Test(@field:NonNull val param: String)
or do I have to do
@Entity
class Test(@field:NonNull val param: String?)
@Entity
class Test(
@field:NonNull
@JsonProperty("param")
private var _param: String?,
@Id
@GeneratedValue
var id: Long? = null
) {
var param: String
get() = this._param!!
set(value) {
this._param = value
}
}
Matthew Gast
08/13/2022, 6:49 PMSiddhartha Juluru
08/13/2022, 6:58 PMJacob
08/14/2022, 5:04 AMthanksforallthefish
08/15/2022, 6:17 AMhttp call -> API level (syntactic validation, like non null, non empty, size, etc) -> domain/logic (business rule validation) -> db (dummy, just read/write)
Siddhartha Juluru
08/15/2022, 2:09 PMMatthew Gast
08/15/2022, 7:28 PMMissingKotlinParameterException
for any non-initialized non-null fields in a Kotlin property, so we catch that in a @ControllerAdvice
exception handler and parse out the property name (which is unfortunately pretty hacky) and send out an appropriate error message. Another downside with this approach is that it will only display one error at a time, so if you have multiple fields which are null that shouldn't be (or any other validation issues), it won't show them all in the error message (as opposed to JSR-380 which can display multiple error messages depending on configuration and implementation).thanksforallthefish
08/15/2022, 7:33 PM!!
when mapping towards the domain.
I am not sure right now how swagger docs generation works with nullable fields annotated with @NotNull
but I think it generates docs with fields marked as mandatory, so all good there too