class DynamicMenuEditorPresenter extends BaseEditor<Plugin, DefaultMetadata> {

    public RuleValidator getMenuItemLabelValidator(final DynamicMenuItem menuItem,
                                                   final DynamicMenuItem editedMenuItem) {
        return new RuleValidator() {

            private String error;

            private NameValidator menuLabelValidator = NameValidator.createNameValidator(getView().emptyMenuLabel(),
                                                                                         getView().invalidMenuLabel());

            @Override
            public boolean isValid(final String value) {
                if (!menuLabelValidator.isValid(value)) {
                    this.error = menuLabelValidator.getValidationError();
                    return false;
                }

                DynamicMenuItem existingItem = getExistingMenuItem(menuItem,
                                                                   editedMenuItem);

                if (existingItem != null) {
                    this.error = getView().duplicatedMenuLabel();
                    return false;
                }

                this.error = null;
                return true;
            }

            @Override
            public String getValidationError() {
                return this.error;
            }
        };
    }

    @Inject public  DynamicMenuEditorPresenter(final View baseView);

}