title: How can I make sure that data contained in Command is the one needed to make the operation?
body: <p>Example, suppose you have an User entity.</p>
  
  <p>The user has <code>id</code>, <code>username</code>, <code>password</code>.
  The id is autogenerated in database.</p>
  
  <p>In an <code>UpdateUserCommand</code>, same data should be used.</p>
  
  <p>In an <code>UpdateUserCommandHandler</code>, we need the ID to make the query <code>update users set password ... where id = :id</code>.</p>
  
  <p>But how can I make sure that I have the data required for building this query? Is the only why a lot of <code>if (!somedata) trow new MissingSomeDataException()</code>?</p>
  
  <p>Example:</p>
  
  <pre><code>if (!isset($data['id'])) {
     throw new Exception('ID is missing');
  if (!isset($data['username'])) {
     throw new Exception('Username is missing');
  if (!isset($data['password'])) {
     throw new Exception('password is missing');
  
  $id = (int) $data['id'];
  if (!isset($data['id'])) {
     throw new Exception('ID is invalid');
  
  $query = $this-&gt;entityManager-&gt;createQuery('update Users u ... where u.id = :id)
  $this-&gt;entityManager-&gt;execute($query, $params);
  </code></pre>