Skip to content

Fixed validator when plugin is disabled #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</constraints>
<properties>
<horizontalAlignment value="0"/>
<text value="Regenerate URN mappings:"/>
<text value="Regenerate URN mappings"/>
</properties>
</component>
<component id="aad3b" class="javax.swing.JTextField" binding="magentoVersion">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,31 @@ public SettingsFormValidator(
}

/**
* Validate form.
* Validates form if plugin is enabled.
*
* @throws ConfigurationException Exception
*/
public void validate() throws ConfigurationException {
if (!form.getSettings().pluginEnabled) {
return;
}

if (!MagentoBasePathUtil.isMagentoFolderValid(form.getMagentoPath())) {
throw new ConfigurationException(
validatorBundle.message("validator.package.validPath")
);
}

final String magentoVersion = form.getMagentoVersion();
if (magentoVersion.length() == 0) {
throw new ConfigurationException(
validatorBundle.message("validator.notEmpty", "Magento Version")
);
}

if (!magentoVersion.matches(RegExUtil.MAGENTO_VERSION)
&& !magentoVersion.equals(MagentoVersionUtil.DEFAULT_VERSION)) {
throw new ConfigurationException(
validatorBundle.message("validator.magentoVersionInvalid")
);
if (form.isBeingUsed()) {
if (!MagentoBasePathUtil.isMagentoFolderValid(form.getMagentoPath())) {
throw new ConfigurationException(
validatorBundle.message("validator.package.validPath")
);
}

final String magentoVersion = form.getMagentoVersion();
if (magentoVersion.length() == 0) {
throw new ConfigurationException(
validatorBundle.message("validator.notEmpty", "Magento Version")
);
}

if (!magentoVersion.matches(RegExUtil.MAGENTO_VERSION)
&& !magentoVersion.equals(MagentoVersionUtil.DEFAULT_VERSION)) {
throw new ConfigurationException(
validatorBundle.message("validator.magentoVersionInvalid")
);
}
}
}
}
}