title: Javalin 4: How to write properly check in call to Validator.check()?
body: <p>I am trying to adopt existing code of parameter validation from Javalin 3 to Javalin 4. It uses Javalin's <code>Validator</code> class. Here's the code I've got (rewritten):</p>
  <pre class="lang-kotlin prettyprint-override"><code>  val messageId = ctx.pathParamAsClass&lt;String&gt;(&quot;messageId&quot;)
      .check(check = { it.trim().matches(Uuid.REGEX) }, errorMessage = &quot;message id must be a UUID&quot;)
      .get()
      .trim()
  </code></pre>
  <p>And I am getting compile error for the <code>check()</code> call:</p>
  <pre><code>e: 
  /home/ivan/.../SourceFile.kt: (53, 6): None of the following functions can be called with the arguments 
  supplied: 
  public final fun check(check: Check&lt;String&gt; /* = (String) -&gt; Boolean */, error: ValidationError&lt;String&gt;): 
  Validator&lt;String&gt; defined in io.javalin.core.validation.Validator
  public final fun check(check: Check&lt;String&gt; /* = (String) -&gt; Boolean */, error: String): Validator&lt;String&gt; defined in 
  io.javalin.core.validation.Validator
  </code></pre>
  <p>I can't understand why there is an error. I assume I should have matched second overload of <code>check()</code>. How to write it correctly?</p>
  <p>Note: I have read <a href="https://javalin.io/migration-guide-javalin-3-to-4" rel="nofollow noreferrer">Javalin 3 to 4 migration guide</a>, which gives example like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>ctx.queryParamAsClass&lt;Int&gt;(&quot;age&quot;)
      .check({ it &gt;= 18 }, ValidationError(&quot;AGE_TOO_LOW&quot;, args = mapOf(&quot;minAge&quot; to 18)))
      .get()
  </code></pre>
  <p>which I seem to follow, except I give it error message as string, but there's matching overload. So what is wrong here?</p>