Package org.apache.sling.validation.api

Examples of org.apache.sling.validation.api.Validator


            Map<String, String>> validators) {
        if (!propertyType.isValid(value)) {
            result.addFailureMessage(property, "Property was expected to be of type " + propertyType.getName());
        }
        for (Map.Entry<Validator, Map<String, String>> validatorEntry : validators.entrySet()) {
            Validator validator = validatorEntry.getKey();
            Map<String, String> arguments = validatorEntry.getValue();
            try {
                String validatorMessage = validator.validate(value, arguments);
                if (validatorMessage != null) {
                    if (validatorMessage.isEmpty()) {
                        validatorMessage = "Property does not contain a valid value for the " + validator
                                .getClass().getName() + " validator";
                    }
                    result.addFailureMessage(property, validatorMessage);
                }
            } catch (SlingValidationException e) {
                // wrap in another SlingValidationException to include information about the property
                throw new SlingValidationException("Could not call validator " + validator
                        .getClass().getName() + " for resourceProperty " + property, e);
            }
        }
    }
View Full Code Here


                    Iterator<Resource> validatorsIterator = validators.listChildren();
                    while (validatorsIterator.hasNext()) {
                        Resource validator = validatorsIterator.next();
                        ValueMap validatorProperties = validator.adaptTo(ValueMap.class);
                        String validatorName = validator.getName();
                        Validator v = vls.getValidator(validatorName);
                        String[] validatorArguments = validatorProperties.get(Constants.VALIDATOR_ARGUMENTS, String[].class);
                        Map<String, String> validatorArgumentsMap = new HashMap<String, String>();
                        if (validatorArguments != null) {
                            for (String arg : validatorArguments) {
                                String[] keyValuePair = arg.split("=");
View Full Code Here

TOP

Related Classes of org.apache.sling.validation.api.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.