/*
 * $Revision: 1.5 $ $Date: 2005/11/03 09:41:48 $
 * (C) 2004 SUGIMOTO Ken-ichi
 * 作成日： 2004/10/2
 */

package feat.v1.preprocess;

import javax.servlet.http.HttpServletRequest;

import feat.v1.Command;
import feat.v1.ContextAccessor;
import feat.v1.PreProcess;
import feat.v1.ValidationError;

public class RequiredParams extends PreProcess {

    //private String[] names;

    /*public RequiredParams(String list) {
        names = Util.stripAll(Util.split(list, ","));
    }*/

    public boolean examine(Command command, String[] params, ContextAccessor acc) throws Exception {
        boolean pass = true;
        HttpServletRequest req = acc.getRequest();
        for(int i=0; i<params.length; i++) {
            String p = req.getParameter(params[i]);
            if ( p == null || p.length() == 0 ) {
                acc.getFeatureErrors().add(new ValidationError(
                        params[i], "必須項目" + params[i] + "が入力されていない",
                        ValidationError.NULL_ERROR));
                pass = false;
            }
        }
        return pass;
    }

}
