String base = param.getType().getBase();
if ("integer".equals(base)) {
try {
Integer.parseInt(paramValue);
} catch (NumberFormatException e) {
context.addMessage(new MessageBuilder().error().source(paramPath)
.code("errors.channelDefinition.param.int")
.defaultText("Value must be an integer").build());
}
} else if ("float".equals(base)) {
try {
Float.parseFloat(paramValue);
} catch (NumberFormatException e) {
context.addMessage(new MessageBuilder().error().source(paramPath)
.code("errors.channelDefinition.param.float")
.defaultText("Value must be a number").build());
}
}
// if this parameter has a restriction in the CPD,
// check it against the restriction
if (param.getType().getRestriction() != null
&& def.getParameters().containsKey(param.getName())) {
CPDParameterTypeRestriction restriction = param.getType().getRestriction();
if ("range".equals(restriction.getType())) {
// For now, lets just not do anything. It doesn't
// look like the existing channel manager logic
// actually uses this restriction for validation
} else if ("enumeration".equals(restriction.getType())) {
// if this restriction is an enumeration of allowed values, check to
// make sure the entered value is in the enumerated list
if (!restriction.getValues().contains(paramValue)) {
context.addMessage(new MessageBuilder().error().source(paramPath)
.code("errors.channelDefinition.param.enum")
.defaultText("Invalid selection").build());
}
}
}