diff --git a/src/NzbDrone.Core/Validation/NzbDroneValidationFailure.cs b/src/NzbDrone.Core/Validation/NzbDroneValidationFailure.cs
new file mode 100644
index 000000000..5eaea8862
--- /dev/null
+++ b/src/NzbDrone.Core/Validation/NzbDroneValidationFailure.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FluentValidation.Results;
+
+namespace NzbDrone.Core.Validation
+{
+ public class NzbDroneValidationFailure : ValidationFailure
+ {
+ public String DetailedDescription { get; set; }
+ public String InfoLink { get; set; }
+
+ public NzbDroneValidationFailure(String propertyName, String error)
+ : base(propertyName, error)
+ {
+
+ }
+ }
+}
diff --git a/src/UI/Content/form.less b/src/UI/Content/form.less
index 66bf13a81..ee8112e89 100644
--- a/src/UI/Content/form.less
+++ b/src/UI/Content/form.less
@@ -88,6 +88,13 @@ h3 {
}
}
+.validation-error {
+ i {
+ text-decoration: none;
+ color: #b94a48;
+ }
+}
+
// Tooltips
.help-inline-checkbox, .help-inline {
diff --git a/src/UI/jQuery/jquery.validation.js b/src/UI/jQuery/jquery.validation.js
index 00f07e24b..fc5abc709 100644
--- a/src/UI/jQuery/jquery.validation.js
+++ b/src/UI/jQuery/jquery.validation.js
@@ -8,9 +8,16 @@ define(
var validationName = error.propertyName.toLowerCase();
+ var errorMessage = this.formatErrorMessage(error);
+
this.find('.validation-errors')
.addClass('alert alert-danger')
- .append('' + error.errorMessage + '
');
+ .append('' + errorMessage + '
');
+
+ if (!validationName || validationName === "") {
+ this.addFormError(error);
+ return;
+ }
var input = this.find('[name]').filter(function () {
return this.name.toLowerCase() === validationName;
@@ -38,11 +45,11 @@ define(
var inputGroup = controlGroup.find('.input-group');
if (inputGroup.length === 0) {
- controlGroup.append('' + error.errorMessage + '');
+ controlGroup.append('' + errorMessage + '');
}
else {
- inputGroup.parent().append('' + error.errorMessage + '');
+ inputGroup.parent().append('' + errorMessage + '');
}
}
@@ -57,12 +64,15 @@ define(
};
$.fn.addFormError = function (error) {
+
+ var errorMessage = this.formatErrorMessage(error);
+
if (this.find('.modal-body')) {
- this.find('.modal-body').prepend('' + error.errorMessage + '
');
+ this.find('.modal-body').prepend('' + errorMessage + '
');
}
-
+
else {
- this.prepend('' + error.errorMessage + '
');
+ this.prepend('' + errorMessage + '
');
}
};
@@ -74,4 +84,24 @@ define(
return this.find('.help-inline.error-message').remove();
};
+ $.fn.formatErrorMessage = function (error) {
+
+ var errorMessage = error.errorMessage;
+ var infoLink = "";
+
+ if (error.infoLink) {
+ if (error.detailedDescription) {
+ errorMessage += " ";
+ }
+ else {
+ errorMessage += " ";
+ }
+ }
+ else if (error.detailedDescription) {
+ errorMessage += " ";
+ }
+
+ return errorMessage;
+ }
+
});