Example #1
0
        public RoleCreateFormValidator(
            IRoleStore roleStore,
            IResourceStore resourceStore,
            ICodeRule codeRule,
            IDescriptionRule descriptionRule,
            IDisplayNameRule displayNameRule)
        {
            this.RoleStore     = roleStore;
            this.ResourceStore = resourceStore;

            RuleFor(x => x.Code)
            .NotEmpty()
            .ApplyRule(codeRule)
            .MustAsync(NotBeExistingCodeAsync)
            .WithMessage("Already existing");

            RuleFor(x => x.Name)
            .NotEmpty()
            .ApplyRule(displayNameRule);

            RuleFor(x => x.Description)
            .ApplyRule(descriptionRule);

            RuleFor(x => x.Permissions)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty()
            .MustAsync(BeExistingResourceCodes)
            .WithMessage("Unexisting resource code detected.");
        }
        public CredentialCreateFormValidator(
            ICredentialStore credentialStore,
            IDisplayNameRule displayNameRule)
        {
            this.CredentialStore = credentialStore;

            RuleFor(x => x.Birthdate)
            .NotEmpty()
            .InclusiveBetween(DateTime.UtcNow.AddYears(-120), DateTime.UtcNow);

            RuleFor(x => x.Email)
            .NotEmpty()
            .EmailAddress()
            .MustAsync(NotBeExistingEmail)
            .WithMessage("Already registered");

            RuleFor(x => x.Password)
            .NotEmpty()
            .MinimumLength(8);

            RuleFor(x => x.PasswordConfirmation)
            .NotEmpty()
            .MinimumLength(8)
            .Must((form, passwordConfirmation) => passwordConfirmation == form.Password)
            .WithMessage("Passwords must be equal");

            RuleFor(x => x.Username)
            .NotEmpty()
            .ApplyRule(displayNameRule)
            .MustAsync(NotBeExistingCredentialId);
        }
Example #3
0
 public CredentialsController(
     ICredentialRoleStore credentialRoleStore,
     ICredentialStore credentialStore,
     IDisplayNameRule displayNameRule)
 {
     this.CredentialRoleStore = credentialRoleStore;
     this.CredentialStore     = credentialStore;
     this.DisplayNameRule     = displayNameRule;
 }
Example #4
0
 public RolesController(
     IRoleStore roleStore,
     IResourceStore resourceStore,
     ICodeRule codeRule,
     IDescriptionRule descriptionRule,
     IDisplayNameRule displayNameRule)
 {
     this.RoleStore       = roleStore;
     this.ResourceStore   = resourceStore;
     this.CodeRule        = codeRule;
     this.DescriptionRule = descriptionRule;
     this.DisplayNameRule = displayNameRule;
 }
Example #5
0
        public SessionFilterValidator(IDisplayNameRule displayNameRule)
        {
            // Para el filtrado no tiene sentido aplicar la regla completa de display name, pero si que le
            // aplica el chequeo de pattern, porque con caracteres ilegales como requeridos solo se van a
            // generar queries inutiles que consumen recursos y nunca traen resultados
            RuleFor(x => x.CredentialId)
            .Matches(displayNameRule.RegexPattern);

            RuleFor(x => x.ExpirationDateMax)
            .GreaterThan(x => x.ExpirationDateMin);

            RuleFor(x => x.LastActiveDateMax)
            .GreaterThan(x => x.LastActiveDateMin);

            RuleFor(x => x.LoginDateMax)
            .GreaterThan(x => x.LoginDateMin);
        }
Example #6
0
        public RoleValidator(
            IResourceStore resourceStore,
            ICodeRule codeRule,
            IDisplayNameRule displayNameRule,
            IDescriptionRule descriptionRule)
        {
            this.ResourceStore = resourceStore;

            RuleFor(x => x.Code)
            .NotEmpty()
            .ApplyRule(codeRule);

            RuleFor(x => x.DisplayName)
            .NotEmpty()
            .ApplyRule(displayNameRule);

            RuleFor(x => x.Description)
            .ApplyRule(descriptionRule);

            RuleFor(x => x.Permissions)
            .NotEmpty()
            .Must(BeUniquePermissionPerResource)
            .MustAsync(BeExistingResourceCodes);
        }