Repository: tipsy/javalin (kotlin)

Issue:
Can't collectErrors() from a NullableValidator (Java)
**Actual behavior (the bug)**
If I try to use `JavalinValidation.collectErrors()` method for a `NullableValidator`, it throws a type error:
```log
java: method collectErrors in class io.javalin.core.validation.JavalinValidation cannot be applied to given types;
  required: io.javalin.core.validation.Validator<?>[]
  found: io.javalin.core.validation.Validator<java.lang.String>,io.javalin.core.validation.Validator<java.lang.String>,io.javalin.core.validation.NullableValidator<java.time.LocalDate>,io.javalin.core.validation.Validator<java.lang.String>,io.javalin.core.validation.Validator<java.lang.String>
  reason: varargs mismatch; io.javalin.core.validation.NullableValidator<java.time.LocalDate> cannot be converted to io.javalin.core.validation.Validator<?>
```

**Expected behavior**
Should build successfully.

**To Reproduce**
1. Create a `NullableValidator`:
```java
    NullableValidator<LocalDate> birthday = ctx.formParamAsClass("birthday", LocalDate.class)
        .allowNullable()
        .check(
            localDate -> localDate == null || localDate.isBefore(now().plusDays(1)),
            "Birthday must be today or earlier."
        );
```
2. Try to `collectErrors()` from it:
```java
JavalinValidation.collectErrors(firstName, lastName, birthday, gender, email);
                                                     ~~~~~~~~
```

Pull request description:
resolves #1529

Patch:
diff --git a/javalin/src/main/java/io/javalin/core/validation/JavalinValidation.kt b/javalin/src/main/java/io/javalin/core/validation/JavalinValidation.kt
index e6a7a67b5..0a499f31d 100644
--- a/javalin/src/main/java/io/javalin/core/validation/JavalinValidation.kt
+++ b/javalin/src/main/java/io/javalin/core/validation/JavalinValidation.kt
@@ -38,10 +38,10 @@ object JavalinValidation {
     fun register(clazz: Class<*>, converter: (String) -> Any?) = converters.put(clazz, converter)
 
     @JvmStatic
-    fun collectErrors(vararg validators: Validator<*>) = collectErrors(validators.toList())
+    fun collectErrors(vararg validators: BaseValidator<*>) = collectErrors(validators.toList())
 
     @JvmStatic
-    fun collectErrors(validators: Iterable<Validator<*>>): Map<String, List<ValidationError<out Any?>>> =
+    fun collectErrors(validators: Iterable<BaseValidator<*>>): Map<String, List<ValidationError<out Any?>>> =
         validators.flatMap { it.errors().entries }.associate { it.key to it.value }
 
     @JvmStatic
@@ -53,5 +53,5 @@ object JavalinValidation {
 }
 
 
-fun Iterable<Validator<*>>.collectErrors(): Map<String, List<ValidationError<out Any?>>> =
+fun Iterable<BaseValidator<*>>.collectErrors(): Map<String, List<ValidationError<out Any?>>> =
     JavalinValidation.collectErrors(this)


Test patch:
diff --git a/javalin/src/test/java/io/javalin/TestValidation.kt b/javalin/src/test/java/io/javalin/TestValidation.kt
index 59e37bab4..95b25dd22 100644
--- a/javalin/src/test/java/io/javalin/TestValidation.kt
+++ b/javalin/src/test/java/io/javalin/TestValidation.kt
@@ -257,15 +257,31 @@ class TestValidation {
                 .check({ !it.contains("-") }, "cannot contain hyphens.")
                 .check({ it.length < 10 }, "cannot be longer than 10 characters.")
 
-            ctx.json(listOf(numberValidator, stringValidator).collectErrors())
+            val nullableValidator = ctx.queryParamAsClass<String>("username")
+                .allowNullable()
+                .check({ it.isNullOrEmpty() || it != "admin" }, "cannot be admin user.")
+
+            ctx.json(listOf(numberValidator, stringValidator, nullableValidator).collectErrors())
+        }
+
+        app.post("/") { ctx ->
+            val bodyValidator = ctx.bodyValidator<Map<String, String>>()
+                .check("first_name", { it.containsKey("first_name") }, "This field is mandatory")
+
+            ctx.json(listOf(bodyValidator).collectErrors())
         }
 
-        http.get("/?number=7&first_name=my-overly-long-first-name").apply {
+        http.get("/?number=7&first_name=my-overly-long-first-name&username=admin").apply {
             assertThat(status).isEqualTo(200)
-            assertThat(body).contains("number", "first_name")
-            assertThat(body).contains("must be greater than 12.", "must be even.")
+            assertThat(body).contains("number", "first_name", "username")
+            assertThat(body).contains("must be greater than 12.", "must be even.", "cannot be admin user.")
             assertThat(body).contains("cannot contain hyphens.", "cannot be longer than 10 characters.")
         }
+
+        http.post("/").body("{\"number\":7}").asString().apply {
+            assertThat(status).isEqualTo(200)
+            assertThat(body).isEqualTo("""{"first_name":[{"message":"This field is mandatory","args":{},"value":{"number":7}}]}""")
+        }
     }
 
     @Test