@Override
public void validate(Object target, Errors errors)
{
DecoratorDynamicTypeNested metadato = (DecoratorDynamicTypeNested) target;
// lo shortname non puo' essere vuoto
String shortName = metadato.getShortName();
// validazione shortname...deve essere unico e non nullo e formato solo
// da caratteri
// alfabetici da 'a-zA-Z','_' e '-'
boolean result = (shortName != null)
&& shortName.matches("^[a-z_\\-A-Z]*$");
if (result && shortName.length() != 0)
{
ValidationResult result2 = null;
// verifica se e' unica
// controllo sul db che non ci siano shortname uguali
ATypeNestedObject<ANestedPropertiesDefinition> object = (ATypeNestedObject) metadato
.getObject();
result2 = getValidatorService().checkShortName(object.getClass(),
object);
if (!result2.isSuccess())
{
errors.rejectValue("shortName", result2.getMessage());
}
if (object.getMask() != null && !object.getMask().isEmpty())
{
int i = 0;
for (ANestedPropertiesDefinition anpd : object.getMask())
{
shortName = anpd.getShortName();
// validazione shortname...deve essere unico e non nullo e
// formato solo da caratteri
// alfabetici da 'a-zA-Z','_' e '-'
result = (shortName != null)
&& shortName.matches("^[a-z_\\-A-Z]*$");
if (result && shortName.length() != 0)
{
if(!shortName.startsWith(metadato.getShortName())) {
errors.rejectValue(
"real.mask[" + i + "].shortName",
"error.message.validation.shortname.nostartswithparentshortname");
}