Examples of ValidationResults


Examples of com.bazaarvoice.commons.data.model.json.schema.validation.ValidationResults

        List<ValidationResults> allUnionResults = Lists.newArrayList();

        // it's not an object, so just validate against all of them and see if there is a schema that's found without errors
        int index = 1;
        for (final JSONSchema unionSchema : getSchemas()) {
            ValidationResults testResults = new ValidationResults();
            unionSchema.validate(obj, buildPath(path, unionSchema, index++), testResults);
            if (!testResults.hasWarningsOrErrors()) {
                // found a good one, so short circuit
                return;
            }

            allUnionResults.add(testResults);
View Full Code Here

Examples of com.bazaarvoice.commons.data.model.json.schema.validation.ValidationResults

    }

    @Override
    public ValidationResults fromJSONObject(JSONObject jsonObject)
            throws JSONException {
        return new ValidationResults().
                addResults(_validationResultMarshaller.fromJSONArray(jsonObject.optJSONArray(getResultsField())));
    }
View Full Code Here

Examples of com.scooterframework.common.validation.ValidationResults

   
    /**
     * Returns controller validation results.
     */
    public static ValidationResults currentValidationResults() {
        ValidationResults vr = (ValidationResults)CurrentThreadCache.get(KEY_ValidationResults);
        if (vr == null) {
            vr = new ValidationResults();
            CurrentThreadCache.set(KEY_ValidationResults, vr);
        }
        return vr;
    }
View Full Code Here

Examples of com.scooterframework.common.validation.ValidationResults

     * @param record an ActiveRecord instance
     * @return List of error messages.
     */
    public static List<Message> getErrorMessages(ActiveRecord record) {
        if (record != null) {
            ValidationResults vr = record.getValidationResults();
            if (vr.failed()) {
                return vr.getErrorMessages();
            }
        }
        return null;
    }
View Full Code Here

Examples of org.apache.bval.ValidationResults

              .findForId("org.apache.bval.example.Address");

        // 1. validate a bean
        BusinessObjectAddress adr = new BusinessObjectAddress();
        BeanValidator<ValidationResults> validator = new BeanValidator();
        ValidationResults results = validator.validate(adr, mb);
        assertEquals(2,
              results.getErrorsByReason().get(Features.Property.MANDATORY).size());

        // 2. validate a map with the same metabean
        validator.setTreatMapsLikeBeans(true);
        results = validator.validate(new HashMap(), mb);
        assertFalse(results.isEmpty());
        assertEquals(2,
              results.getErrorsByReason().get(Features.Property.MANDATORY).size());

        // 3. validate as empty map (jsr303 behavior)
        validator.setTreatMapsLikeBeans(false);
        results = validator.validate(new HashMap(), mb);
        assertTrue(results.isEmpty());
    }
View Full Code Here

Examples of org.apache.bval.ValidationResults

        MetaBean info = finder.findForClass(BusinessObject.class);
        BusinessObject object = new BusinessObject();
        object.setAddress(new BusinessObjectAddress());
        object.getAddress().setOwner(object);
        BeanValidator<ValidationResults> validator = new BeanValidator();
        ValidationResults results = validator.validate(object, info);
        assertTrue(results.hasErrorForReason(Reasons.MANDATORY));
        assertTrue(results.hasError(object, null));
        assertTrue(results.hasError(object.getAddress(), null));

        assertTrue(
              validator.validateProperty(object, info.getProperty("firstName")).hasError(
                    object, "firstName"));
View Full Code Here

Examples of org.apache.bval.ValidationResults

              .findForId("org.apache.bval.example.Address");

        // 1. validate a bean
        BusinessObjectAddress adr = new BusinessObjectAddress();
        BeanValidator<ValidationResults> validator = new BeanValidator();
        ValidationResults results = validator.validate(adr, mb);
        assertEquals(2,
              results.getErrorsByReason().get(Features.Property.MANDATORY).size());

        // 2. validate a map with the same metabean
        validator.setTreatMapsLikeBeans(true);
        results = validator.validate(new HashMap(), mb);
        assertFalse(results.isEmpty());
        assertEquals(2,
              results.getErrorsByReason().get(Features.Property.MANDATORY).size());

        // 3. validate as empty map (jsr303 behavior)
        validator.setTreatMapsLikeBeans(false);
        results = validator.validate(new HashMap(), mb);
        assertTrue(results.isEmpty());
    }
View Full Code Here

Examples of org.apache.bval.ValidationResults

        MetaBean info = finder.findForClass(BusinessObject.class);
        BusinessObject object = new BusinessObject();
        object.setAddress(new BusinessObjectAddress());
        object.getAddress().setOwner(object);
        BeanValidator<ValidationResults> validator = new BeanValidator();
        ValidationResults results = validator.validate(object, info);
        assertTrue(results.hasErrorForReason(Reasons.MANDATORY));
        assertTrue(results.hasError(object, null));
        assertTrue(results.hasError(object.getAddress(), null));

        assertTrue(
              validator.validateProperty(object, info.getProperty("firstName")).hasError(
                    object, "firstName"));
View Full Code Here

Examples of org.apache.bval.ValidationResults

        super(name);
    }

    public void setUp() throws Exception {
        super.setUp();
        results = new ValidationResults();
    }
View Full Code Here

Examples of org.apache.bval.ValidationResults

              .findForId("org.apache.bval.example.Address");

        // 1. validate a bean
        BusinessObjectAddress adr = new BusinessObjectAddress();
        BeanValidator<ValidationResults> validator = new BeanValidator<ValidationResults>();
        ValidationResults results = validator.validate(adr, mb);
        assertEquals(2,
              results.getErrorsByReason().get(Features.Property.MANDATORY).size());

        // 2. validate a map with the same metabean
        validator.setTreatMapsLikeBeans(true);
        results = validator.validate(new HashMap<String, Object>(), mb);
        assertFalse(results.isEmpty());
        assertEquals(2,
              results.getErrorsByReason().get(Features.Property.MANDATORY).size());

        // 3. validate as empty map (jsr303 behavior)
        validator.setTreatMapsLikeBeans(false);
        results = validator.validate(new HashMap<Object, Object>(), mb);
        assertTrue(results.isEmpty());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.