title: Disable 1/yes/on and 0/no/off and allow only true/false to be passed via query-param or path-param
body: <p>I want to disable Spring built-in deserialization of integer 0/1 and the strings
  no/off yes/on that are mapped to false/true respectively when they are
  passed via query-parameter or path-variable.
  When any value that is not true/false is passed I want to throw IllegalArgumentException.</p>
  <p>First I've implemented my own StringToBooleanConverter:</p>
  <pre><code>import org.springframework.core.convert.converter.Converter;
  import org.springframework.stereotype.Component;
  
  @Component
  public class StringToBooleanConverter implements Converter&lt;String, Boolean&gt; {
  
      @Override
      public Boolean convert(String source) {
          String value = source.trim().toLowerCase();
  
          if (&quot;true&quot;.equals(value)) {
              return Boolean.TRUE;
          } else if (&quot;false&quot;.equals(value)) {
              return Boolean.FALSE;
          }
  
          throw new IllegalArgumentException(&quot;Invalid boolean value '&quot; + source + &quot;'&quot;);
      }
  }
  </code></pre>
  <p>And since I've provided an implementation of similar class spring will use my StringToBooleanConverter and not the one from <code>org.springframework.core.convert.support</code></p>
  <p>But here is where my problem arise. When I send e.g. 0 code is reaching to the <code>IllegalArgumentException</code> and then execution passed to <code>CustomBooleanEditor</code> in the
  <code>org.springframework.beans.propertyeditors</code> and the method <code>public void setAsText(@Nullable String text) throws IllegalArgumentException {}</code> is invoked and does almost the same logic
  as <code>StringToBooleanConverter</code>.</p>
  <p>How can I disable Spring from calling this method and use only the <code>StringToBooleanConverter</code>?</p>