title: Validate the invalid json input to avoid foreign-key constraint error
body: <p>I am doing a validation task for my Web API project. It exposes APIs to the front-end.  The front-end should input valid values in the json file, but sometimes, if the invalid values coming it cause exceptions in my project. </p>
  
  <p>For example, <code>someId</code> cannot be <code>0</code> or other invalid values. Because if 0 was set to <code>someId</code>, the DB will yell the foreign key constraints error.</p>
  
  <p>My solution to this is using the attribute validation</p>
  
  <pre class="lang-cs prettyprint-override"><code> [Range(1, 10, ErrorMessage = "{0} Values must be in range {1} to {2}")]
   public int? someId { get; set; }
  </code></pre>
  
  <p>So it will prevent the invalid values from UI. But the little hassle is I need to hard code the valid data range in each fields. So I am asking if it has a better solution than mine?</p>