Package com.alibaba.citrus.service.form

Examples of com.alibaba.citrus.service.form.Validator


* @author Michael Zhou
*/
public class AllOfValuesValidator extends AbstractMultiValuesValidator {
    @Override
    protected boolean validate(Context context, Object[] values) {
        Validator validator = getValidator();
        List<String> messages = createArrayList(getValidators().size());

        context.getMessageContext().put("allMessages", messages);

        for (int i = 0; i < values.length; i++) {
            Object value = values[i];
            Context newContext = newContext(context, validator, value);

            newContext.getMessageContext().put("valueIndex", i);

            if (!validator.validate(newContext)) {
                messages.add(validator.getMessage(newContext));
                return false;
            }
        }

        return true;
View Full Code Here


* @author Michael Zhou
*/
public class AnyOfValuesValidator extends AbstractMultiValuesValidator {
    @Override
    protected boolean validate(Context context, Object[] values) {
        Validator validator = getValidator();
        List<String> messages = createArrayList(getValidators().size());

        context.getMessageContext().put("allMessages", messages);

        for (int i = 0; i < values.length; i++) {
            Object value = values[i];
            Context newContext = newContext(context, validator, value);

            newContext.getMessageContext().put("valueIndex", i);

            if (validator.validate(newContext)) {
                return true;
            } else {
                messages.add(validator.getMessage(newContext));
            }
        }

        return false;
    }
View Full Code Here

* @author Michael Zhou
*/
public class NoneOfValuesValidator extends AbstractMultiValuesValidator {
    @Override
    protected boolean validate(Context context, Object[] values) {
        Validator validator = getValidator();

        for (Object value : values) {
            Context newContext = newContext(context, validator, value);

            if (validator.validate(newContext)) {
                return false;
            }
        }

        return true;
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.form.Validator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.