konform-kt / konform

Portable validations for Kotlin
https://www.konform.io
MIT License
652 stars 39 forks source link

Remove ifPresent #11

Closed raderio closed 2 years ago

raderio commented 5 years ago
UserProfile::age ifPresent {
    minimum(0)
    maximum(150)
}

Why it is neccesary to have ifPresent? Just apply validation rules ony if value is not null in any case.

cies commented 2 years ago

In that case minimum and maximum (amoung others) need to work both on a nullable context and on a non-nullable context.

I think the ifPresent also makes the intent of the code more clear to the reader.

nlochschmidt commented 2 years ago

I agree with @cies.