konform-kt / konform

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

Kotlintest/Kotest Matchers #17

Closed sksamuel closed 4 years ago

sksamuel commented 4 years ago

Kotest (previously kotlintest) has added support for Konform testing. https://github.com/kotest/kotest

Example:


   val validateUser = Validation<UserProfile> {
      UserProfile::fullName {
         minLength(2)
         maxLength(100)
      }

      UserProfile::age ifPresent {
         minimum(0)
         maximum(150)
      }
   }

      val user1 = UserProfile("Alice", 25)
      validateUser shouldBeValid user1

      val user2 = UserProfile("A", -1)
      validateUser.shouldBeInvalid(user2) {
         it.shouldContainError(UserProfile::fullName, "must have at least 2 characters")
         it.shouldContainError(UserProfile::age, "must be at least '0'")
      }

Would you like me to open a PR to add instructions to the readme?

nlochschmidt commented 4 years ago

I am glad that you find this project useful.

Yes, feel free to open a pull request.

sksamuel commented 4 years ago

PR created https://github.com/konform-kt/konform/pull/19