add missing validators
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using FluentValidation;
|
||||
using zero.Core.Api;
|
||||
using zero.Core.Entities;
|
||||
|
||||
namespace zero.Core.Validation
|
||||
{
|
||||
public class MediaValidator : ZeroValidator<IMedia>
|
||||
{
|
||||
public MediaValidator(IBackofficeStore store)
|
||||
{
|
||||
RuleFor(x => x.Name).Length(2, 80);
|
||||
RuleFor(x => x.IsActive).Equal(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FluentValidation;
|
||||
using zero.Core.Api;
|
||||
using zero.Core.Entities;
|
||||
|
||||
namespace zero.Core.Validation
|
||||
{
|
||||
public class PageValidator : ZeroValidator<IPage>
|
||||
{
|
||||
public PageValidator()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using zero.Core.Extensions;
|
||||
|
||||
namespace zero.Core.Validation
|
||||
{
|
||||
public class SetupModelValidator : AbstractValidator<SetupModel>
|
||||
public class SetupModelValidator : ZeroValidator<SetupModel>
|
||||
{
|
||||
public SetupModelValidator()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ using System;
|
||||
|
||||
namespace zero.Core.Validation
|
||||
{
|
||||
public class UserRoleValidator : AbstractValidator<IUserRole>
|
||||
public class UserRoleValidator : ZeroValidator<IUserRole>
|
||||
{
|
||||
const string SECTION_CLAIM = "section.";
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</slot>
|
||||
<slot name="settings-properties"></slot>
|
||||
</div>
|
||||
<div class="ui-box" v-if="value.id">
|
||||
<div class="ui-box is-light" v-if="value.id">
|
||||
<slot name="infos">
|
||||
<ui-property v-if="value.id" label="@ui.id" :is-text="true">
|
||||
{{value.id}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<ui-daterangepicker :value="{ from: value.publishDate, to: value.unpublishDate }" @input="onRangeChange" :class="{ 'is-primary': value.publishDate || value.unpublishDate }" />
|
||||
</ui-property>
|
||||
</div>
|
||||
<div class="ui-box">
|
||||
<div class="ui-box is-light">
|
||||
<ui-property v-if="!isCreate" label="@ui.id" :is-text="true">
|
||||
{{value.id}}
|
||||
</ui-property>
|
||||
|
||||
@@ -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<IApplication, Application>();
|
||||
//services.AddTransient<IValidator<IApplication>, ApplicationValidator>();
|
||||
services.AddTransient<ICountry, Country>();
|
||||
services.AddTransient<ILanguage, Language>();
|
||||
services.AddTransient<ITranslation, Translation>();
|
||||
@@ -30,6 +29,16 @@ namespace zero.Web.Defaults
|
||||
services.AddTransient<IMediaFolder, MediaFolder>();
|
||||
services.AddTransient<IPreview, Preview>();
|
||||
|
||||
services.AddTransient<IValidator<IApplication>, ApplicationValidator>();
|
||||
services.AddTransient<IValidator<ICountry>, CountryValidator>();
|
||||
services.AddTransient<IValidator<ILanguage>, LanguageValidator>();
|
||||
services.AddTransient<IValidator<ITranslation>, TranslationValidator>();
|
||||
services.AddTransient<IValidator<IPage>, PageValidator>();
|
||||
services.AddTransient<IValidator<IMedia>, MediaValidator>();
|
||||
services.AddTransient<IValidator<IMediaFolder>, MediaFolderValidator>();
|
||||
services.AddTransient<IValidator<IUserRole>, UserRoleValidator>();
|
||||
services.AddTransient<IValidator<IUser>, BackofficeUserValidator>();
|
||||
|
||||
services.AddTransient<IApplicationsApi, ApplicationsApi>();
|
||||
services.AddTransient<ICountriesApi, CountriesApi>();
|
||||
services.AddTransient<ILanguagesApi, LanguagesApi>();
|
||||
|
||||
Reference in New Issue
Block a user