=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java 2013-08-23 16:00:30 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueController.java 2013-09-17 18:23:30 +0000 @@ -45,6 +45,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.system.util.ValidationUtils; import org.hisp.dhis.user.CurrentUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -123,6 +124,14 @@ } value = StringUtils.trimToNull( value ); + + String valid = ValidationUtils.dataValueIsValid( value, dataElement ); + + if ( valid != null ) + { + ContextUtils.conflictResponse( response, "Invalid value: " + value + ", must match data element type: " + dataElement.getType() ); + return; + } String storedBy = currentUserService.getCurrentUsername(); === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java 2013-09-17 18:23:30 +0000 @@ -29,6 +29,8 @@ */ import com.opensymphony.xwork2.Action; + +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.dataelement.DataElement; @@ -189,21 +191,8 @@ Date now = new Date(); - if ( storedBy == null ) - { - storedBy = "[unknown]"; - } - - if ( value != null && value.trim().length() == 0 ) - { - value = null; - } - - if ( value != null ) - { - value = value.trim(); - } - + value = StringUtils.trimToNull( value ); + // --------------------------------------------------------------------- // Validate value according to type from data element // ---------------------------------------------------------------------