* @throws NSValidation.ValidationException when the validation fails
*/
public void validateValueForQueryKey(Object value, String key) throws NSValidation.ValidationException {
if( value instanceof NSKeyValueCoding.Null) { value = null; }
D2WContext d2wContext = d2wContext();
String propertyKey = propertyKeyFromDisplayGroupKey(key);
d2wContext().setPropertyKey(propertyKey);
if (null == value && !ERXValueUtilities.booleanValueWithDefault(d2wContext.valueForKey(ValidationKeys.AllowsEmptyQueryValue), true)) {
throw ERXValidationFactory.defaultFactory().createCustomException(null, propertyKey, value, "QueryValueRequired");
}
EOAttribute attribute = null;
if (ERXValueUtilities.booleanValue(d2wContext.valueForKey("isAttribute"))) {
attribute = d2wContext.attribute();
} else {
EORelationship relationship = d2wContext.relationship();
if (relationship != null && !(value instanceof EOEnterpriseObject)) {
String keyWhenRelationship = (String)d2wContext.valueForKey("keyWhenRelationship");
if (keyWhenRelationship != null) {
EOEntity destinationEntity = relationship.destinationEntity();
attribute = destinationEntity.attributeNamed(keyWhenRelationship);
}
}