init backend
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
using AipsCore.Domain.Common.ValueObjects;
|
||||
|
||||
namespace AipsCore.Domain.Models.User.ValueObjects;
|
||||
|
||||
public record UserId(string IdValue) : DomainId(IdValue);
|
||||
33
dotnet/AipsCore/Domain/Models/User/ValueObjects/Username.cs
Normal file
33
dotnet/AipsCore/Domain/Models/User/ValueObjects/Username.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using AipsCore.Domain.Abstract;
|
||||
using AipsCore.Domain.Abstract.Rule;
|
||||
using AipsCore.Domain.Abstract.ValueObject;
|
||||
using AipsCore.Domain.Common.Validation;
|
||||
using AipsCore.Domain.Common.Validation.Rules;
|
||||
using AipsCore.Domain.Common.ValueObjects;
|
||||
using AipsCore.Domain.Models.User.Validation;
|
||||
|
||||
namespace AipsCore.Domain.Models.User.ValueObjects;
|
||||
|
||||
public record Username : AbstractValueObject
|
||||
{
|
||||
public string UsernameValue { get; init; }
|
||||
|
||||
public Username(string UsernameValue)
|
||||
{
|
||||
this.UsernameValue = UsernameValue;
|
||||
Validate();
|
||||
}
|
||||
|
||||
private const int MinimumLength = 8;
|
||||
private const int MaximumLength = 20;
|
||||
|
||||
protected override ICollection<IRule> GetValidationRules()
|
||||
{
|
||||
return
|
||||
[
|
||||
new MinLengthRule(UsernameValue, MinimumLength),
|
||||
new MaxLengthRule(UsernameValue, MaximumLength),
|
||||
new UsernameCharsetRule(UsernameValue)
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user