title: What are patterns to validate data prior to HttpClient call?
body: <p>I need help determining what is a good pattern for validating data prior to making an HttpClient call in an angular service. Without exception every angular service I have seen does no parameter validation prior to making the actual HttpClient call, e.g.</p>
  <pre><code>doStuff(data: FooRequest): Observable&lt;FooResponse&gt; {
    return this.http.post('/api/foo/bar', data);
  }
  </code></pre>
  <p>what I am looking for is what if I want to validate <code>data</code> prior to making the http post but still return an observable from the <code>doStuff</code> method?</p>
  <p>I was thinking I could just use something like this but surely there has to be a better way, right?</p>
  <pre><code>doStuff(data: FooRequest): Observable&lt;FooResponse&gt; {
    return new Observable(sub =&gt; {
      if (!data.stuff) {
        sub.error(new Error('stuff is missing'));
      }
      ...
    });
  }
  </code></pre>