Examples of ValidatorDescriptor


Examples of com.opensymphony.workflow.loader.ValidatorDescriptor

        if (!(descriptor instanceof ValidatorDescriptor))
        {
            throw new IllegalArgumentException("Descriptor must be a ValidatorDescriptor.");
        }

        ValidatorDescriptor validatorDescriptor = (ValidatorDescriptor) descriptor;
        String value = (String) validatorDescriptor.getArgs().get(param);

        if (value!=null && value.trim().length() > 0)
        {
            return value;
        }
View Full Code Here

Examples of com.opensymphony.workflow.loader.ValidatorDescriptor

        if (!(descriptor instanceof ValidatorDescriptor))
        {
            throw new IllegalArgumentException("Descriptor must be a ValidatorDescriptor.");
        }

        ValidatorDescriptor validatorDescriptor = (ValidatorDescriptor) descriptor;
        String value = (String) validatorDescriptor.getArgs().get(param);

        if (value!=null && value.trim().length() > 0)
        {
            return value;
        }
View Full Code Here

Examples of net.sourceforge.annovalidator.validation.annotations.ValidatorDescriptor

                    LOG.debug(bar.toString());
                    LOG.debug(header);
                    LOG.debug(bar.toString());
                }
                if (isInStep(object, validationAnnotation, step)) {
                    ValidatorDescriptor validatorDescriptor =
                        validationAnnotation
                            .annotationType().getAnnotation(
                                    ValidatorDescriptor.class);
                    try {
                        if (!validateObject(
                                object, validatorDescriptor,
                                validationAnnotation)) {
                          String targetFieldName = (String) ReflectionUtil
                            .determineAnnotationParameterValue(
                                validationAnnotation,
                                "targetFieldName");
                          if (StringUtils.isBlank(targetFieldName)) {
                            // TODO: Make a proper exception for this.
                            throw new RuntimeException(
                                "Cannot supply a blank value for " +
                                "\"targetFieldName\" in a class level " +
                                "validator");
                          }
                            result.recordValidationViolation(
                                    targetFieldName,
                                    generateErrorCode(
                                            object,
                                            targetFieldName,
                                            validatorDescriptor,
                                            validationAnnotation),
                                    object);
                        }
                    } catch (ReportedValidationException e) {
                        result.recordValidationViolation(
                                e.getField(),
                                generateErrorCode(e, object),
                                e.getArguments());
                       
                    }
                }
            }
        }
        for (Field field : fields) {
            // Scan for validation annotations
            for (Annotation validationAnnotation : field.getAnnotations()) {
              // See if nested validation should occur on this field
              if (validationAnnotation.annotationType().equals(
                  ValidateNested.class)) {
                boolean isCollection =
                  Boolean.valueOf(
                  ReflectionUtil.determineAnnotationParameterValue(
                      validationAnnotation,
                      "isCollection").toString());
                Class<?> fieldType;
                NestedResult nestedResult = null;
                boolean anyError = false;
                if (isCollection) {
                  int collectionIndex = 0;
                  for (Object fieldValue :
                (Collection<?>) ReflectionUtil
                  .determineFieldValue(object, field)) {                   
                   
                    fieldType = fieldValue.getClass();
                   
                        nestedResult =
                          new NestedResult(
                          field.getName()
                            + "[" + collectionIndex + "]",
                          fieldType.getSimpleName());
                       
                    AnnotatedObjectValidator.validate(
                        fieldValue,
                        nestedResult);
                   
                    if (nestedResult.hasNestedValidationErrors()) {
                      anyError = true;
                      nestedResult.mergeWithMainResults(result);
                    }
                   
                    collectionIndex++;
                    nestedResult = null;
                  }
                  if (anyError) {
                        result.recordValidationViolation(
                        field.getName(),
                        generateErrorCode(
                            object.getClass().getSimpleName(),
                            field.getName(),
                            "nestedValidation"),
                        ReflectionUtil.determineFieldValue(
                            object, field));
                  }
                } else {
                    fieldType = field.getType();
                    nestedResult =
                      new NestedResult(
                          field.getName(),
                          fieldType.getSimpleName());
                    validateNestedField(object, field, step, nestedResult);
                    if (nestedResult.hasNestedValidationErrors()) {
                        result.recordValidationViolation(
                            field.getName(),
                            generateErrorCode(
                                object.getClass().getSimpleName(),
                                field.getName(),
                                "nestedValidation"),
                            ReflectionUtil.determineFieldValue(object, field));
                      nestedResult.mergeWithMainResults(result);
                    }
                }
              }
              // Proceed with normal validators.
                if (validationAnnotation.annotationType().isAnnotationPresent(
                        ValidatorDescriptor.class)) {
                    if (LOG.isDebugEnabled()) {
                        String header = "Running Field Validator "
                            + validationAnnotation.annotationType()
                                .getSimpleName()
                            + " on field \"" + field.getName() + "\"";
                        StringBuffer bar = new StringBuffer();
                        while (bar.length() < header.length()) {
                            bar.append("-");
                        }
                        LOG.debug("");
                        LOG.debug(bar.toString());
                        LOG.debug(header);
                        LOG.debug(bar.toString());
                    }
                    // Validation annotation found!
                    if (isInStep(field, validationAnnotation, step)) {
                        ValidatorDescriptor validatorDescriptor =
                            validationAnnotation
                                .annotationType().getAnnotation(
                                        ValidatorDescriptor.class);
                        try {
                            if (!validateField(object, field,
View Full Code Here

Examples of org.richfaces.validator.ValidatorDescriptor

    }

    private void setupComponentValidator(Validator... validators) {
        expect(input.getValidators()).andStubReturn(validators);
        for (Validator validator : validators) {
            ValidatorDescriptor validatorDescriptor = environment.createMock(ValidatorDescriptor.class);
            expect((Class) validatorDescriptor.getImplementationClass()).andStubReturn(validator.getClass());
            expect(validatorDescriptor.getMessage()).andStubReturn(VALIDATION_ERROR);
            expect(facesValidatorService.getValidatorDescription(environment.getFacesContext(), input, validator, null))
                .andStubReturn(validatorDescriptor);
        }
    }
View Full Code Here

Examples of org.richfaces.validator.ValidatorDescriptor

        setupComponentValidator(validator);
        setupBeanValidator();
        expect(input.getAttributes()).andStubReturn(Collections.<String, Object>emptyMap());
        Collection<ValidatorDescriptor> validators = checkValidator();
        assertEquals(1, validators.size());
        ValidatorDescriptor validatorDescriptor = Iterables.getOnlyElement(validators);
        assertSame(validator.getClass(), validatorDescriptor.getImplementationClass());
        assertEquals(VALIDATION_ERROR, validatorDescriptor.getMessage());
        controller.verify();
    }
View Full Code Here

Examples of org.richfaces.validator.ValidatorDescriptor

    public void testBeanValidators() throws Exception {
        setupBeanValidator(beanValidatorDescriptor);
        expect(input.getAttributes()).andStubReturn(Collections.<String, Object>emptyMap());
        Collection<ValidatorDescriptor> validators = checkValidator();
        assertEquals(1, validators.size());
        ValidatorDescriptor validatorDescriptor = Iterables.getOnlyElement(validators);
        assertSame(beanValidatorDescriptor, validatorDescriptor);
        controller.verify();
    }
View Full Code Here

Examples of org.richfaces.validator.ValidatorDescriptor

        } else {
            expect(mockBehavior.getConverter(behaviorContext)).andStubReturn(null);
        }
        Collection<ValidatorDescriptor> validatorDescriptors = new ArrayList<ValidatorDescriptor>(validators.length);
        for (Class<?> validator : validators) {
            ValidatorDescriptor validatorDescriptor = controller.createNiceMock(ValidatorDescriptor.class);
            setupDescription(validator, validatorDescriptor);
            validatorDescriptors.add(validatorDescriptor);
        }
        expect(mockBehavior.getValidators(behaviorContext)).andReturn(validatorDescriptors);
        expect(input.getClientId(environment.getFacesContext())).andStubReturn("foo:bar");
View Full Code Here

Examples of org.richfaces.validator.ValidatorDescriptor

        } else {
            expect(mockBehavior.getConverter(behaviorContext)).andStubReturn(null);
        }
        Collection<ValidatorDescriptor> validatorDescriptors = new ArrayList<ValidatorDescriptor>(validators.length);
        for (Class<?> validator : validators) {
            ValidatorDescriptor validatorDescriptor = controller.createNiceMock(ValidatorDescriptor.class);
            setupDescription(validator, validatorDescriptor);
            validatorDescriptors.add(validatorDescriptor);
        }
        expect(mockBehavior.getValidators(behaviorContext)).andReturn(validatorDescriptors);
        expect(input.getClientId(environment.getFacesContext())).andStubReturn("foo:bar");
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.