title: Check if date is a valid one
body: <p>Following is the scenario:</p>
  
  <p>I have a <code>String</code> date and a date format which is different. Ex.:<br>
  date: 2016-10-19<br>
  dateFormat: "DD-MM-YYYY".</p>
  
  <p>I need to check if this date is a valid date.</p>
  
  <p>I have tried following things</p>
  
  <pre><code>var d = moment("2016-10-19",dateFormat);
  </code></pre>
  
  <p><code>d.isValid()</code> is returning <code>false</code> every time. Does not Moment.js parse the date in the given format?</p>
  
  <p>Then I tried to format the date in <code>DD-MM-YYYY</code> first and then pass it to Moment.js:</p>
  
  <pre><code>var d = moment("2016-10-19").format(dateFormat);
  var date = moment(d, dateFormat);
  </code></pre>
  
  <p>Now <code>date.isValid()</code> is giving me the desired result, but here the Moment.js date object is created twice. How can I avoid this? Is there a better solution?</p>
  
  <p>FYI I am not allowed to change the <code>dateFormat</code>.</p>