}
public void validateBasicInfo(ChannelDefinitionForm def, MessageContext context) {
Matcher matcher = FunctionalNameType.VALID_FNAME_PATTERN.matcher(def.getFname());
if (StringUtils.isEmpty(def.getFname())) {
context.addMessage(new MessageBuilder().error().source("fName")
.code("errors.channelDefinition.fName.empty")
.defaultText("Please enter an fname").build());
} else if (!matcher.matches()) {
context.addMessage(new MessageBuilder().error().source("fName")
.code("errors.channelDefinition.fName.invalid")
.defaultText("Fnames may only contain letters, numbers, dashes, and underscores").build());
}
// if this is a new channel and the fname is already taken
else if (def.getId() == -1 && channelStore.getChannelDefinition(def.getFname()) != null) {
context.addMessage(new MessageBuilder().error().source("fName")
.code("errors.channelDefinition.fName.duplicate")
.defaultText("This fname is already in use").build());
}
if (StringUtils.isEmpty(def.getTitle())) {
context.addMessage(new MessageBuilder().error().source("title")
.code("errors.channelDefinition.title.empty")
.defaultText("Please enter a title").build());
}
if (StringUtils.isEmpty(def.getName())) {
context.addMessage(new MessageBuilder().error().source("name")
.code("errors.channelDefinition.name.empty")
.defaultText("Please enter a name").build());
}
// if this is a new channel and the name is already taken
if (def.getId() == -1 && channelStore.getChannelDefinitionByName(def.getName()) != null) {
context.addMessage(new MessageBuilder().error().source("name")
.code("errors.channelDefinition.name.duplicate")
.defaultText("This name is already in use").build());
}