Package com.alibaba.citrus.service.form

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


    @Test
    public void init_fieldConfig() throws Exception {
        V v = newValidatorFor_AbstractCompositeValidatorTests();
        FieldConfig fieldConfig = createMock(FieldConfig.class);
        Validator v1 = createMock(Validator.class);
        Validator v2 = createMock(Validator.class);
        Validator v3 = createMock(Validator.class);

        v1.init(fieldConfig);
        v2.init(fieldConfig);
        v3.init(fieldConfig);

        replay(fieldConfig, v1, v2, v3);

        v.setValidators(createValidatorList(v1, v2, v3));
View Full Code Here


    }

    @Test
    public void init_clone() throws Exception {
        V v = newValidatorFor_AbstractCompositeValidatorTests();
        Validator v1 = createMock(Validator.class);
        Validator v2 = createMock(Validator.class);
        Validator v1copy = createMock(Validator.class);
        Validator v2copy = createMock(Validator.class);

        expect(v1.clone()).andReturn(v1copy);
        expect(v2.clone()).andReturn(v2copy);

        replay(v1, v2, v1copy, v2copy);
View Full Code Here

        validator.setMessage("test");
    }

    @Override
    protected void initFor_AbstractValidatorTests(V validator) {
        Validator v1 = createMock(Validator.class);
        Validator v2 = createMock(Validator.class);
        Validator v3 = createMock(Validator.class);

        validator.setValidators(createValidatorList(v1, v2, v3));
    }
View Full Code Here

        return getValidators().get(0);
    }

    /** 用子validator验证,并取得其错误信息。 */
    protected final boolean doValidate(Context context) {
        Validator validator = getValidator();
        Context newContext = newContext(context, validator);

        if (!validator.validate(newContext)) {
            context.setMessage(validator.getMessage(newContext));
            return false;
        }

        return true;
    }
View Full Code Here

        List<Validator> validators = getValidators();

        assertTrue(!validators.isEmpty(), "no validators");

        for (Iterator<Validator> i = validators.iterator(); i.hasNext(); ) {
            Validator validator = i.next();

            if (i.hasNext()) {
                assertTrue(validator instanceof When, "expected <when>");
            } else {
                assertTrue(validator instanceof When || validator instanceof Otherwise,
View Full Code Here

* @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

    /**
     * ����validator��֤����ȡ���������Ϣ��
     */
    protected final boolean doValidate(Context context) {
        Validator validator = getValidator();
        Context newContext = newContext(context, validator);

        if (!validator.validate(newContext)) {
            context.setMessage(validator.getMessage(newContext));
            return false;
        }

        return true;
    }
View Full Code Here

        List<Validator> validators = getValidators();

        assertTrue(!validators.isEmpty(), "no validators");

        for (Iterator<Validator> i = validators.iterator(); i.hasNext();) {
            Validator validator = i.next();

            if (i.hasNext()) {
                assertTrue(validator instanceof When, "expected <when>");
            } else {
                assertTrue(validator instanceof When || validator instanceof Otherwise,
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.