title: How could I put a constraint on a literal string parameter
body: <p>I have to say that the title is too poor to be able to describe the problem but that was the only thing I could think of. Anyway, suppose I've been given the following enum:</p>
  
  <pre><code>public enum DocumentType{
        IdCard=0,
        Passport,
        DriversLicense
  }
  </code></pre>
  
  <p>And I have a method that accepts a string and returns the above enum:</p>
  
  <pre><code>public DocumentType GetDocTypeByString(string docType){
      switch (docType)
      {
         case "ID":
           return DocumentType.IdCard;
         case "PASS"
           return DocumentType.Passport;
         //and so on
      }
  }
  </code></pre>
  
  <p>Now, what if the passed string does not meet any of the switch conditions? The silliest thing would be to make the return type object, but that's something that hardly ever somebody would do it. if the enum was mine, I would add an additional value called something like "None" and return that in case of no match, but I have no control on it. Then I thought, whether it would be possible to constrain the input to certain values. As far as the C# is concerned, I am almost totally sure that it's not possible, but I decided to ask anyway. Would would you recommend in this case?</p>