Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated tenantId to allow one digit ending with dot. updated/added Mo… #116

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Application/Common/Validators/RegularExpressionValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ public static class ValidationConstants
public const string LettersSpacesUnderscores = @"^[A-Za-z_ ]+$";
public const string LettersSpacesUnderscoresMessage = "{0} must contain only letters, spaces, and underscores.";

public const string LettersSpacesCommaApostorphe = @"^[A-Za-z ',’]+$";
public const string LettersSpacesCommaApostropheMessage = "{0} must contain only letters, spaces, comma and an apostrophe.";

public const string AlphabetsDigitsSpaceSlashHyphenDot= @"^[a-zA-Z0-9\s\\\/\-.]+$";
public const string AlphabetsDigitsSpaceSlashHyphenDotMessage = "{0} must contain only alphabet (both uppercase and lowercase), digit, space, backslash, forward slash, hyphen, and dot.";

public const string DateMustBeInPast = "Date must be in the past.";
public const string DateMustBeInFuture = "Date must be in the future.";

Expand All @@ -13,6 +19,9 @@ public static class ValidationConstants

public const string GuidMessage = "{0} must contain a valid Guid";

public const string Numbers = @"^[0-9]*$";
public const string NumbersMessage = "{0} must contain only numbers";

public const string AlphaNumeric = @"^[a-zA-Z0-9]*$";
public const string AlphaNumericMessage = "{0} must contain only alphanumeric characters";

Expand All @@ -30,8 +39,8 @@ public static class ValidationConstants
public const int MaximumPageSize = 50;
public const string MaximumPageSizeMessage = "Page size must be between 1 and 50.";

public const string TenantId = @"^[0-9]+(?:\\.[0-9]+)*\\.$";
public const string TenantIdMessage = "Must start with a number and end with a period for example 1.2.1.";
public const string TenantId = @"^(\d+(\.\d+)*\.)$";
public const string TenantIdMessage = "Invalid format for Tenant Id";

public const string TenantDomain = @"^@[a-z0-9]+(?:[-]?[a-z0-9]+)*(?:\.[a-z0-9]+(?:[-]?[a-z0-9]+)*)+$";
public const string TenantDomainMessage = "Must be in the format '@example.com'";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ public ApplicationUserDtoValidator(
.NotEmpty().WithMessage(_localizer["Tenant name is required"])
.Matches(ValidationConstants.TenantId).WithMessage(_localizer[ValidationConstants.TenantIdMessage]);

RuleFor(x => x.ProviderId)
.MaximumLength(50).WithMessage(_localizer["Provider must be less than 50 characters"])
.NotEmpty().WithMessage(_localizer["Provider is required"])
.Matches(ValidationConstants.AlphaNumeric).WithMessage(_localizer[string.Format(ValidationConstants.AlphaNumericMessage, "Provider Id")]);

RuleFor(x => x.DisplayName)
.MaximumLength(100).WithMessage(_localizer["Display Name is required and must be less than or equal to 100 characters"])
.NotEmpty().WithMessage(_localizer["Display Name is required"])
.Matches(ValidationConstants.AlphaNumeric).WithMessage(_localizer[string.Format(ValidationConstants.AlphaNumericMessage, "Display Name")]);
.Matches(ValidationConstants.NameCompliantWithDMS).WithMessage(_localizer[string.Format(ValidationConstants.NameCompliantWithDMSMessage, "Display Name")]);

RuleFor(x => x.Email)
.NotEmpty().WithMessage(_localizer["E-mail is required"])
Expand Down Expand Up @@ -58,14 +53,16 @@ public ApplicationUserDtoValidator(

RuleFor(x => x.PhoneNumber)
.MaximumLength(20).WithMessage(_localizer["Mobile number must be less than or equal to 20 digits"])
.Matches(ValidationConstants.AlphaNumeric).WithMessage(_localizer[string.Format(ValidationConstants.AlphaNumericMessage, "Mobile number")]);
.Matches(ValidationConstants.Numbers).WithMessage(_localizer[string.Format(ValidationConstants.NumbersMessage, "Mobile number")]);

RuleFor(x => x.MemorablePlace)
.MaximumLength(50).WithMessage(_localizer["Memorable place must be less than or equal to 50 characters"])
.Matches(ValidationConstants.AlphaNumeric).WithMessage(_localizer[string.Format(ValidationConstants.AlphaNumericMessage, "Memorable place")]);
.Matches(ValidationConstants.LettersSpacesCommaApostorphe).WithMessage(_localizer[string.Format(ValidationConstants.LettersSpacesCommaApostropheMessage, "Memorable place")]);

RuleFor(x => x.MemorableDate)
.NotEmpty().WithMessage(_localizer["Memorable date is required"]);
.NotEmpty().WithMessage(_localizer["Memorable date is required"])
.MaximumLength(50).WithMessage(_localizer["Memorable place must be less than or equal to 50 characters"])
.Matches(ValidationConstants.AlphabetsDigitsSpaceSlashHyphenDot).WithMessage(_localizer[string.Format(ValidationConstants.AlphabetsDigitsSpaceSlashHyphenDotMessage, "Memorable date")]); ;

RuleForEach(x => x.Notes).ChildRules(notes =>
{
Expand Down
Loading