[CHANGE] Updated ValidationResult to monad version
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using DotBased.AspNet.Authority.Managers;
|
||||
using DotBased.AspNet.Authority.Models.Authority;
|
||||
using DotBased.AspNet.Authority.Models.Validation;
|
||||
using DotBased.AspNet.Authority.Monads;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Validators;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using DotBased.AspNet.Authority.Managers;
|
||||
using DotBased.AspNet.Authority.Models.Authority;
|
||||
using DotBased.AspNet.Authority.Models.Validation;
|
||||
using DotBased.AspNet.Authority.Monads;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Validators;
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using DotBased.AspNet.Authority.Managers;
|
||||
using DotBased.AspNet.Authority.Models.Authority;
|
||||
using DotBased.AspNet.Authority.Models.Validation;
|
||||
using DotBased.AspNet.Authority.Monads;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Validators;
|
||||
|
||||
@@ -17,6 +18,6 @@ public class PasswordEqualsValidator : IPasswordValidator
|
||||
errors.Add(new ValidationError(ValidatorId, $"{ValidationBase}.InUse", "User uses this password already!"));
|
||||
}
|
||||
|
||||
return errors.Count > 0 ? ValidationResult.Failed(errors) : ValidationResult.Ok();
|
||||
return errors.Count > 0 ? ValidationResult.Fail(errors) : ValidationResult.Success();
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
using DotBased.AspNet.Authority.Managers;
|
||||
using DotBased.AspNet.Authority.Models.Authority;
|
||||
using DotBased.AspNet.Authority.Models.Validation;
|
||||
using DotBased.AspNet.Authority.Monads;
|
||||
using DotBased.Extensions;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Validators;
|
||||
@@ -57,7 +58,7 @@ public class PasswordOptionsValidator : IPasswordValidator
|
||||
errors.Add(new ValidationError(ValidatorId, $"{ValidationBase}.UniqueChars", $"Password must contain at least {passwordOptions.MinimalUniqueChars} unique chars."));
|
||||
}
|
||||
|
||||
return await Task.FromResult(errors.Count > 0 ? ValidationResult.Failed(errors) : ValidationResult.Ok());
|
||||
return await Task.FromResult(errors.Count > 0 ? ValidationResult.Fail(errors) : ValidationResult.Success());
|
||||
}
|
||||
|
||||
private bool ContainsDigit(string strVal) => strVal.Any(char.IsDigit);
|
||||
|
@@ -2,6 +2,7 @@ using DotBased.AspNet.Authority.Managers;
|
||||
using DotBased.AspNet.Authority.Models.Authority;
|
||||
using DotBased.AspNet.Authority.Models.Options;
|
||||
using DotBased.AspNet.Authority.Models.Validation;
|
||||
using ValidationResult = DotBased.AspNet.Authority.Monads.ValidationResult;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Validators;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class UserValidator : IUserValidator
|
||||
chars.AddRange(user.UserName.Where(userNameChar => userOptions.UserNameCharacters.Contains(userNameChar)));
|
||||
}
|
||||
|
||||
if (chars.Count <= 0) return errors.Count > 0 ? ValidationResult.Failed(errors) : ValidationResult.Ok();
|
||||
if (chars.Count <= 0) return errors.Count > 0 ? ValidationResult.Fail(errors) : ValidationResult.Success();
|
||||
var errorCode = "";
|
||||
var description = "";
|
||||
switch (userOptions.UserNameCharacterListType)
|
||||
@@ -76,6 +77,6 @@ public class UserValidator : IUserValidator
|
||||
errors.Add(new ValidationError(ValidatorId, $"{ValidationBase}.InvalidUserName", "No username given!"));
|
||||
}
|
||||
|
||||
return errors.Count > 0 ? ValidationResult.Failed(errors) : ValidationResult.Ok();
|
||||
return errors.Count > 0 ? ValidationResult.Fail(errors) : ValidationResult.Success();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user