diff --git a/zero.Core/Validation/LanguageValidator.cs b/zero.Core/Validation/LanguageValidator.cs index f7b3671b..2a1b9c37 100644 --- a/zero.Core/Validation/LanguageValidator.cs +++ b/zero.Core/Validation/LanguageValidator.cs @@ -14,7 +14,7 @@ namespace zero.Core.Validation RuleFor(x => x.Code).Length(2, 10).Culture(); RuleFor(x => x.IsDefault).Unique(store).When(x => x.IsDefault).WithMessage("@language.errors.default_unique"); RuleFor(x => x.IsDefault).ExpectAnyUnique(store, expectedValue: true).When(x => !x.IsDefault).WithMessage("@language.errors.needs_default"); - RuleFor(x => x.InheritedLanguageId).Must((entity, value) => !entity.Id.Equals(value, StringComparison.InvariantCultureIgnoreCase)).WithMessage("@language.errors.fallback_invalid"); + RuleFor(x => x.InheritedLanguageId).Must((entity, value) => !entity.Id.Equals(value, StringComparison.InvariantCultureIgnoreCase)).When(x => !x.Id.IsNullOrEmpty()).WithMessage("@language.errors.fallback_invalid"); RuleFor(x => x.InheritedLanguageId).Equal((string)null).When(x => x.IsDefault).WithMessage("@language.errors.default_no_fallback"); RuleFor(x => x.InheritedLanguageId).Exists(store); RuleFor(x => x.IsOptional).Equal(false).When(x => x.IsDefault).WithMessage("@language.errors.default_not_optional"); diff --git a/zero.Core/Validation/MediaValidator.cs b/zero.Core/Validation/MediaValidator.cs new file mode 100644 index 00000000..c7027fdd --- /dev/null +++ b/zero.Core/Validation/MediaValidator.cs @@ -0,0 +1,15 @@ +using FluentValidation; +using zero.Core.Api; +using zero.Core.Entities; + +namespace zero.Core.Validation +{ + public class MediaValidator : ZeroValidator + { + public MediaValidator(IBackofficeStore store) + { + RuleFor(x => x.Name).Length(2, 80); + RuleFor(x => x.IsActive).Equal(true); + } + } +} \ No newline at end of file diff --git a/zero.Core/Validation/PageValidator.cs b/zero.Core/Validation/PageValidator.cs new file mode 100644 index 00000000..742b5218 --- /dev/null +++ b/zero.Core/Validation/PageValidator.cs @@ -0,0 +1,14 @@ +using FluentValidation; +using zero.Core.Api; +using zero.Core.Entities; + +namespace zero.Core.Validation +{ + public class PageValidator : ZeroValidator + { + public PageValidator() + { + + } + } +} \ No newline at end of file diff --git a/zero.Core/Validation/SetupModelValidator.cs b/zero.Core/Validation/SetupModelValidator.cs index 7a767934..975dec7b 100644 --- a/zero.Core/Validation/SetupModelValidator.cs +++ b/zero.Core/Validation/SetupModelValidator.cs @@ -4,7 +4,7 @@ using zero.Core.Extensions; namespace zero.Core.Validation { - public class SetupModelValidator : AbstractValidator + public class SetupModelValidator : ZeroValidator { public SetupModelValidator() { diff --git a/zero.Core/Validation/UserRoleValidator.cs b/zero.Core/Validation/UserRoleValidator.cs index 41a4872d..0ca8da25 100644 --- a/zero.Core/Validation/UserRoleValidator.cs +++ b/zero.Core/Validation/UserRoleValidator.cs @@ -6,7 +6,7 @@ using System; namespace zero.Core.Validation { - public class UserRoleValidator : AbstractValidator + public class UserRoleValidator : ZeroValidator { const string SECTION_CLAIM = "section."; diff --git a/zero.Web.UI/App/editor/editor.vue b/zero.Web.UI/App/editor/editor.vue index 7f6fcc4f..ddae8038 100644 --- a/zero.Web.UI/App/editor/editor.vue +++ b/zero.Web.UI/App/editor/editor.vue @@ -22,7 +22,7 @@ -
+
{{value.id}} diff --git a/zero.Web.UI/App/pages/pages/page-info.vue b/zero.Web.UI/App/pages/pages/page-info.vue index 94ae3889..6d143cff 100644 --- a/zero.Web.UI/App/pages/pages/page-info.vue +++ b/zero.Web.UI/App/pages/pages/page-info.vue @@ -17,7 +17,7 @@
-
+
{{value.id}} diff --git a/zero.Web/Defaults/ZeroBackofficePlugin.cs b/zero.Web/Defaults/ZeroBackofficePlugin.cs index cbd07342..23db6821 100644 --- a/zero.Web/Defaults/ZeroBackofficePlugin.cs +++ b/zero.Web/Defaults/ZeroBackofficePlugin.cs @@ -16,11 +16,10 @@ namespace zero.Web.Defaults { public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { - services.AddAll(typeof(IValidator<>), ServiceLifetime.Scoped); + //services.AddAll(typeof(IValidator<>), ServiceLifetime.Scoped); //services.AddAll(typeof(IValidator), ServiceLifetime.Scoped); services.AddTransient(); - //services.AddTransient, ApplicationValidator>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -30,6 +29,16 @@ namespace zero.Web.Defaults services.AddTransient(); services.AddTransient(); + services.AddTransient, ApplicationValidator>(); + services.AddTransient, CountryValidator>(); + services.AddTransient, LanguageValidator>(); + services.AddTransient, TranslationValidator>(); + services.AddTransient, PageValidator>(); + services.AddTransient, MediaValidator>(); + services.AddTransient, MediaFolderValidator>(); + services.AddTransient, UserRoleValidator>(); + services.AddTransient, BackofficeUserValidator>(); + services.AddTransient(); services.AddTransient(); services.AddTransient();