=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java 2014-12-22 09:30:50 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java 2014-12-22 09:52:13 +0000 @@ -118,6 +118,11 @@ validationViolations.add( new ValidationViolation( "Value is not a valid password." ) ); } + if ( PropertyType.COLOR == property.getPropertyType() && !ValidationUtils.isValidHexColor( value ) ) + { + validationViolations.add( new ValidationViolation( "Value is not a valid color (in hex format)." ) ); + } + /* TODO add proper validation for both Points and Polygons, ValidationUtils only supports points at this time if ( PropertyType.GEOLOCATION == property.getPropertyType() && !ValidationUtils.coordinateIsValid( value ) ) { === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2014-12-22 09:33:56 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java 2014-12-22 09:52:13 +0000 @@ -28,29 +28,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM; -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_BOOL; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_DATE; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_NEGATIVE_INT; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_NUMBER; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_PERCENTAGE; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_POSITIVE_INT; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_TRUE_ONLY; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_UNIT_INTERVAL; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT; - -import java.awt.geom.Point2D; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.commons.validator.routines.DateValidator; import org.apache.commons.validator.routines.EmailValidator; import org.apache.commons.validator.routines.UrlValidator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.datavalue.DataValue; +import org.jdom.Verifier; + +import java.awt.geom.Point2D; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.hisp.dhis.dataelement.DataElement.*; /** * @author Lars Helge Overland @@ -226,11 +216,11 @@ Matcher matcher = POINT_PATTERN.matcher( coordinate ); - if( matcher.find() && matcher.groupCount() == 2 ) + if ( matcher.find() && matcher.groupCount() == 2 ) { return new Point2D.Double( Double.parseDouble( matcher.group( 1 ) ), Double.parseDouble( matcher.group( 2 ) ) ); } - else return null; + else return null; } /** @@ -251,7 +241,7 @@ * given data element. Considers the value to be valid if null or empty. * Returns a string if the valid is invalid, possible * values are: - * + *
*