/*
 * Generated by XCodeGen v1.0
 * Sun Jul 07 16:05:46 EDT 2002
 */

package xcodegen.sample.presentation.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;


/**
 * 
 *
 * @author Herve Tchepannou
 * @version 
 *
 * @struts:form name="Login"
 *              
 */
public class LoginForm 
    extends ActionForm
{

///////////////////////////////////////////////////
// Fields
///////////////////////////////////////////////////


    /**  */
    private String email;

    /**  */
    private String password;


///////////////////////////////////////////////////
// Constructors
///////////////////////////////////////////////////

    public LoginForm ()
    {
    }
    

    
///////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////

    public ActionErrors validate( ActionMapping mapping, HttpServletRequest request )
    {

        ActionErrors errors = new ActionErrors();


        if ( !checkRule_1 () )
        {
            errors.add( "email_required", new ActionError( "email_required" ) );
        }

        if ( !checkRule_2 () )
        {
            errors.add( "email_format", new ActionError( "email_format" ) );
        }

        if ( !checkRule_3 () )
        {
            errors.add( "password_required", new ActionError( "password_required" ) );
        }

        return errors;
    }
        
    private boolean checkRule_1 ()
    {
        
        return     true
            && (     this.email != null

 )
            && (             true
         && this.email.length() >= 1             
 )
    
;
        }
    private boolean checkRule_2 ()
    {
        
        return     true
            && (     this.email != null

 )
            && (             this.email.matches( ".*@.*" )
    
 )
    
;
        }
    private boolean checkRule_3 ()
    {
        
        return     true
            && (     this.password != null

 )
            && (             true
         && this.password.length() >= 1             
 )
    
;
        }
    

///////////////////////////////////////////////////
// accessor methods for attributes
///////////////////////////////////////////////////

    
    /**
     * Getter of <code>email</code>
     * @see #email
     * @struts:form-field form-name="email"
     */
    public String getEmail () { return this.email; }
    
    /** 
     * Setter of <code>email</code>
     * @see #email
     */
    public void setEmail ( String value ) { this.email = value; }
    
    /**
     * Getter of <code>password</code>
     * @see #password
     * @struts:form-field form-name="password"
     */
    public String getPassword () { return this.password; }
    
    /** 
     * Setter of <code>password</code>
     * @see #password
     */
    public void setPassword ( String value ) { this.password = value; }
}
