title: Knockout: regex and required validation overlapping? Won't pass my tests
body: <p>In a ViewModel I have a few properties which have required and regular expression validations (on the same property) as follows:</p>
  <pre><code>// ...other properties...
  MaxDays: ko.observable(&quot;&quot;).extend({
      required: { message: &quot;You have to specify the maximum number of days.&quot; },
      pattern: {
          message: &quot;Please enter a valid number.&quot;,
          params: '[0-9]+$',
          maxLength: 10
      }
  }),
  // ...other properties...
  </code></pre>
  <p>I'm using Jasmine to test and I noticed that if I assign a value that doesn't match the expression, the value is ignored and it runs its own test for &quot;required&quot; as if there's no data in that property.</p>
  <pre><code>// ... describe, other &quot;it&quot; statements, etc...
  it(&quot;should complain if there's incorrect data&quot;, function () {
  
      viewModel.MaxDays(&quot;Zweiundzwanzig&quot;);
  
      expect(viewModel.errors().length).toBeGreaterThan(0);
      expect(viewModel.errors()).toContain('Please enter a valid number.');
  
      console.log(viewModel.errors());
  
  });
  // ...
  </code></pre>
  <p>When I run the test it fails. the errors collection is filled with an error but not because I entered a string when it should be a number. It fails because it thinks that property is empty. I get the error message from &quot;required&quot; instead of the message from &quot;pattern&quot;:</p>
  <p><img src="https://i.stack.imgur.com/P3Oap.png" alt="enter image description here" /></p>
  <p>The funny part is that it works on the UI, so if I go on the field bound to that property and type a string value, it will fire the regex validation and put the correct error message beside the field.</p>
  <p>Can anyone point out what I'm missing here?</p>