kalidation icon indicating copy to clipboard operation
kalidation copied to clipboard

returnOf on a nested property always fails

Open a-xp opened this issue 2 years ago • 0 comments

class MyTest {
    
    class A {
        fun t(): Int {
            return 0
        }
    }
    
    data class B(val nested: A = A())

    @Test
    fun test() {
        val spec = validationSpec {
            constraints<B> {
                property(B::nested) {
                    valid()
                }
            }
            constraints<A> {
                returnOf(A::t) {
                    positive()
                }
            }
        }
        spec.validate(B())
    }
}

Throws: A.t() kotlin.Int must belong to class B(nested=A())) to be callable

a-xp avatar Jun 12 '23 15:06 a-xp