title: Best way for a form controller to expose parsed data from the form it manages?
body: <p>I come from a Java background and am getting up to speed on Angular 1.5.8+typescript.  </p>
  
  <p>I have a form controller that crunches the raw fields from a form and produces a data structure.  An example of the sort of thing it might do:  take a raw address, parse it into standard format and lookup latitude and longitude.</p>
  
  <p>I'm trying to figure out the best way to expose interpreted form data to the rest of the application, and wanted to see if either one are "acceptable," standard ways of doing things.</p>
  
  <p>The way I'm partial to would be to create two classes, one representing the fully parsed data from the form, and one representing a partial subset of that data.   </p>
  
  <p>Callers interested in the data would call either getCompleteData or getIncompleteData on my controller, depending on whether they wanted a real time peek, or complete data (if available). Details about the actual form fields and their values would not be exposed outside of the controller.</p>
  
  <p>Another way I thought about doing this was to add a bunch of methods to the controller for accessing each bit of processed data, each one with a Maybe return.</p>
  
  <p><em>Method 1:</em></p>
  
  <pre><code>class MyFormController {
      address() : Maybe&lt;Address&gt; = {
           if (theForm.street.length &gt; 0) {
              just(new Address(theForm.street, theForm.city, theForm.state, findLatAndLong(...)));
            } else { nothing() }
      }
  
      street() : string = { theForm.street}
  }
  </code></pre>
  
  <p><em>Method 2:</em></p>
  
  <pre><code>class CompleteParsedData {
      address: Address;
      firstName: string;
      middleInitial: Maybe&lt;string&gt;;
      lastName: string;
  }
  
  class IncompleteParsedData {
      address: Maybe&lt;Address;
      firstName: Maybe&lt;string&gt;;
      middleInitial: Maybe&lt;string&gt;;
      lastName: Maybe&lt;string&gt;;
  }
  
  class MyFormController {
     getParsedData: Try[CompleteParsedData]; //return complete parsed data or validation error explaining what's missing
     getIncompleteData: IncompleteParsedData; //return as much of the parsed data as we can infer from current raw data
  }
  </code></pre>
  
  <p>This question might be a better fit in the code review stack exchange -- let me know if I should move it!</p>