ingo@0: package de.intevation.flys.client.shared;
ingo@0: 
ingo@0: /**
ingo@0:  * <p>
ingo@0:  * FieldVerifier validates that the name the user enters is valid.
ingo@0:  * </p>
ingo@0:  * <p>
ingo@0:  * This class is in the <code>shared</code> package because we use it in both
ingo@0:  * the client code and on the server. On the client, we verify that the name is
ingo@0:  * valid before sending an RPC request so the user doesn't have to wait for a
ingo@0:  * network round trip to get feedback. On the server, we verify that the name is
ingo@0:  * correct to ensure that the input is correct regardless of where the RPC
ingo@0:  * originates.
ingo@0:  * </p>
ingo@0:  * <p>
ingo@0:  * When creating a class that is used on both the client and the server, be sure
ingo@0:  * that all code is translatable and does not use native JavaScript. Code that
ingo@0:  * is note translatable (such as code that interacts with a database or the file
ingo@0:  * system) cannot be compiled into client side JavaScript. Code that uses native
ingo@0:  * JavaScript (such as Widgets) cannot be run on the server.
ingo@0:  * </p>
ingo@0:  */
ingo@0: public class FieldVerifier {
ingo@0: 
ingo@0:   /**
ingo@0:    * Verifies that the specified name is valid for our service.
sascha@615:    *
ingo@0:    * In this example, we only require that the name is at least four
ingo@0:    * characters. In your application, you can use more complex checks to ensure
ingo@0:    * that usernames, passwords, email addresses, URLs, and other fields have the
ingo@0:    * proper syntax.
sascha@615:    *
ingo@0:    * @param name the name to validate
ingo@0:    * @return true if valid, false if invalid
ingo@0:    */
ingo@0:   public static boolean isValidName(String name) {
ingo@0:     if (name == null) {
ingo@0:       return false;
ingo@0:     }
ingo@0:     return name.length() > 3;
ingo@0:   }
ingo@0: }