Bug 128142 [DataBinding] IDomainValidator needs to provide partial validation / be merged with IValidator
Suppose I want to restrict an Integer field to the range 1-10. I would use an IntegerValidator and a String2IntConverter on the target2model side. I would then write an IDomainValidator to restrict the integer value coming from the String2IntConverter to the range 1-10. But this would not result in ideal behavior. The partial validation in the IntegerValidator would permit any value from Integer.MIN to Interger.MAX. But since the domain model only allows a value in the range 1-10, it makes no sense to permit a leading - sign or more than two digits in the field. The way things stand currently, the user could enter 365 in the field and wouldn't find out until they tried to leave the field that this is an invalid value. The solution appears to be to change the partial validation algorithm to the following: Call the conversion validator's partial validation method. If this succeeds: Call the conversion validator's full validation method. If this succeeds: Use the converter to convert the value to the domain's data type Pass converted value to partial validation method on domain's validator. If we do this, then the domain's validator will be able to do both partial and full validation. If we do this, then IDomainValidator will have all the same methods as IValidator, so it can go away and we can just use IValidator in both instances.
bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/DefaultBindSupportFactory.java
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ObjectToPrimitiveValidator;
import org.eclipse.core.databinding.validation.ReadOnlyValidator;
import org.eclipse.core.databinding.validation.String2BytePrimitiveValidator;
import org.eclipse.core.databinding.validation.String2ByteValidator;
import org.eclipse.core.databinding.validation.String2DateValidator;
import org.eclipse.core.databinding.validation.String2DoublePrimitiveValidator;
import org.eclipse.core.databinding.validation.String2DoubleValidator;
import org.eclipse.core.databinding.validation.String2FloatPrimitiveValidator;
import org.eclipse.core.databinding.validation.String2FloatValidator;
import org.eclipse.core.databinding.validation.String2IntegerPrimitiveValidator;
import org.eclipse.core.databinding.validation.String2IntegerValidator;
import org.eclipse.core.databinding.validation.String2LongPrimitiveValidator;
import org.eclipse.core.databinding.validation.String2LongValidator;
import org.eclipse.core.databinding.validation.String2ShortPrimitiveValidator;
import org.eclipse.core.databinding.validation.String2ShortValidator;
import org.eclipse.core.internal.databinding.ClassLookupSupport;
import org.eclipse.core.internal.databinding.Pair;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
 * Default bind support factory. This factory adds the following converters and
 * validators:
 * 
 * TODO list converters and validators
 * 
 * @since 1.0
 * 
 */
public final class DefaultBindSupportFactory extends BindSupportFactory {