title: How to do validation with React Native package tcomb-form-native
body: <p>While entering an email in the TextInput, it should validate and display the error message based on whether the entered email is valid or not? I'm using tcomb form validation. How to add email validation in tcomb form? Below is the code.</p>
  
  <pre><code>import React, { Component } from 'react';
  import {
    AppRegistry,
    Text,
    Image,
    View,
    Button,
    StyleSheet,
    TextInput,
    Linking,
    Alert,
    Navigator
  } from 'react-native';
  import t from 'tcomb-form-native';
  
  const Form = t.form.Form;
  
  // here we are: define your domain model
  const LoginFields = t.struct({
    username: t.String,              // a required string
    password: t.String,   // a required string
  });
  
  const options = {
    fields: {
      password: {
        type: 'password',
        placeholder: 'Password',
  
      },
      username: {
        placeholder: 'e.g: abc@gmail.com',
        error: 'Insert a valid email'
      }
    }
  }; // optional rendering options (see documentation)
  
  export default class Login extends Component {
    _onSubmit() {
      // Alert.alert('Button has been pressed!');
      const value = this.refs.form.getValue();
      if (value) { // if validation fails, value will be null
        console.log(value); // value here is an instance of LoginFields
      }
      this.props.navigator.push({
        id: 'Home'
      });
    }
    render() {
      return (
        &lt;View style={styles.containerView}&gt;
        &lt;Form
          ref="form"
          type={LoginFields}
          options={options}
        /&gt;
          &lt;Text style={{color: 'blue', marginBottom: 10}}
            onPress={() =&gt; Linking.openURL('https://www.google.co.in')}&gt;
            Forgot Password?
          &lt;/Text&gt;
          &lt;Button
              onPress={this._onSubmit.bind(this)}
              title="Login"
              style={styles.loginButton}
              accessibilityLabel="Ok, Great!"
            /&gt;
        &lt;/View&gt;
      );
    }
  };
  
  const styles= StyleSheet.create({
    containerView: {
      flex: 1,
      justifyContent: 'center',
      backgroundColor: '#ffebcd',
      borderStyle: 'solid',
      borderColor: '#000000'
    },
    loginText: {
      fontSize: 20,
      marginBottom: 10
    },
    inputFields: {
      fontSize: 20,
      borderStyle: 'solid',
      borderColor: '#000000',
      borderRadius: 30,
      marginBottom: 10
    },
    loginButton: {
      backgroundColor: '#34A853'
    }
  });
  </code></pre>