Source code: com/clra/web/ValidateMember.java
1 /*
2 * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3 * Distributed under the GPL license. See doc/COPYING.
4 * $RCSfile: ValidateMember.java,v $
5 * $Date: 2003/02/26 03:38:46 $
6 * $Revision: 1.3 $
7 */
8
9 package com.clra.web;
10
11 import org.apache.struts.action.ActionErrors;
12 import org.apache.struts.action.ActionError;
13 import java.util.ArrayList;
14 import java.util.List;
15
16 /**
17 * Base class for validation checks of MemberInfoForm.
18 *
19 * @version $Id: ValidateMember.java,v 1.3 2003/02/26 03:38:46 rphall Exp $
20 * @author <a href="mailto:rphall@pluto.njcc.com">Rick Hall</a>
21 */
22 abstract class ValidateMember {
23
24 /** The form that is being validated */
25 protected final MemberInfoForm form;
26
27 ValidateMember( MemberInfoForm f ) {
28 this.form = f;
29 if ( f == null ) {
30 throw new IllegalArgumentException( "null form" );
31 }
32 }
33
34 /**
35 * Subclasses must define this method to check whether data contained in
36 * a form is valid within some validation context.
37 * @param errors a non-null ActionErrors object to which subclasses should
38 * add error messages (if the form is invalid).
39 */
40 abstract void validate( ActionErrors errors );
41
42 protected final void validateRequiredValue( String PROPERTY,
43 String messageKey, String value, ActionErrors errors ) {
44
45 if ( value == null || value.trim().length() == 0 ) {
46 ActionError ae = new ActionError(messageKey);
47 errors.add( PROPERTY, ae );
48 }
49
50 return;
51 } // validateRequiredValue(String,String,ActionErrors)
52
53 } // ValidateMember
54
55 /*
56 * $Log: ValidateMember.java,v $
57 * Revision 1.3 2003/02/26 03:38:46 rphall
58 * Added copyright and GPL license
59 *
60 * Revision 1.2 2003/02/18 04:37:39 rphall
61 * Working for MEMBEREDIT, ADMINEDIT, ADMINCREATE
62 *
63 * Revision 1.1 2003/02/11 21:13:15 rphall
64 * Separate class for specific validation task; stubbed implementation
65 *
66 */
67