Email validation in a custom module
In a custom module, consider using PHP's built function for email validation: filter_var().

$email_a = 'joe@example.com';
$email_b = 'bogus';

if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
    echo "This ($email_a) email address is considered valid.";
}
if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
    echo "This ($email_b) email address is considered valid.";
}


This code will go into a validation function. A validation function can be added as an element to the form array (see the form API for details) that you linked to. If your module is named spade, for example, your form may be in function spade_form(). Your submit may then be put in function spade_form_submit(), and your validation would be in function spade_form_validate(). This is the default handler for validation.

See the following links for more information.


http://php.net/manual/en/filter.examples.validation.php
http://php.net/manual/en/filter.filters.validate.php
https://www.drupal.org/project/examples 


The first example is exactly what you're looking for (and the example that I copied above). The last link contains the examples module, which has a lot of great form examples.