Skip to content

Commit

Permalink
fix(cab) : add spaces to the validation strings and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGLauria committed Dec 6, 2024
1 parent 6292890 commit 846642a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions DVSRegister/Models/CAB/Provider/CompanyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CompanyViewModel
public int ProviderId { get; set; }
[Required(ErrorMessage = "Enter the digital identity and attribute provider's registered name")]
[MaximumLength(160, ErrorMessage = "The company's registered name must be less than 161 characters")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž&@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "The company's registered name must contain only letters, numbers and accepted characters.")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž &@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "The company's registered name must contain only letters, numbers and accepted characters.")]
public string? RegisteredName { get; set; }
public string? TradingName { get; set; }
public bool? HasRegistrationNumber { get; set; }
Expand All @@ -26,12 +26,12 @@ public class CompanyViewModel

[RequiredIf("HasParentCompany",true, ErrorMessage = "Enter the registered name of your parent company")]
[MaximumLength(160, ErrorMessage = "Your company's registered name must be less than 161 characters")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž&@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "Your parent company's registered name must contain only letters, numbers and accepted characters.")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž &@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "Your parent company's registered name must contain only letters, numbers and accepted characters.")]
public string? ParentCompanyRegisteredName { get; set; }

[RequiredIf("HasParentCompany", true,ErrorMessage = "Enter the location of your parent company")]
[MaximumLength(160, ErrorMessage = "Your company's location must be less than 161 characters")]
[AcceptedCharacters(@"^[A-Za-z.,:-]+$", ErrorMessage = "Your parent company's location must contain only letters, numbers and accepted characters.")]
[AcceptedCharacters(@"^[A-Za-z .,:-]+$", ErrorMessage = "Your parent company's location must contain only letters, numbers and accepted characters.")]
public string? ParentCompanyLocation { get; set; }
}
}
6 changes: 4 additions & 2 deletions DVSRegister/Models/CAB/Provider/ProfileSummaryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ProfileSummaryViewModel
{
[Required(ErrorMessage = "Enter the digital identity and attribute provider's registered name")]
[MaximumLength(160, ErrorMessage = "The company's registered name must be less than 161 characters")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž&@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "The company's registered name must contain only letters, numbers and accepted characters.")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž &@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "The company's registered name must contain only letters, numbers and accepted characters.")]
public string? RegisteredName { get; set; }
public string? TradingName { get; set; }

Expand All @@ -29,11 +29,13 @@ public class ProfileSummaryViewModel

[Required(ErrorMessage = "Enter the registered name of your parent company")]
[MaximumLength(160, ErrorMessage = "Your company's registered name must be less than 161 characters")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž&@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "Your parent company's registered name must contain only letters, numbers and accepted characters.")]
[AcceptedCharacters(@"^[A-Za-zÀ-ž &@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$", ErrorMessage = "Your parent company's registered name must contain only letters, numbers and accepted characters.")]

public string? ParentCompanyRegisteredName { get; set; }

[Required(ErrorMessage = "Enter the location of your parent company")]
[MaximumLength(160, ErrorMessage = "Your company's location must be less than 161 characters")]
[AcceptedCharacters(@"^[A-Za-z .,:-]+$", ErrorMessage = "Your parent company's location must contain only letters, numbers and accepted characters.")]
public string? ParentCompanyLocation { get; set; }

public PrimaryContactViewModel? PrimaryContact { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion Unit-testing/CompanyNameValidationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Tests
[SetUp]
public void Setup()
{
_pattern = @"^[A-Za-zÀ-ž&@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$";
_pattern = @"^[A-Za-zÀ-ž &@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$";
}

[Test]
Expand All @@ -29,6 +29,7 @@ public void Setup()
[TestCase("NameWithSolidus\\/\\", true)]
[TestCase("NameWithSigns*=", true)]
[TestCase("NameWithSymbols#%+", true)]
[TestCase("Name With Spaces", true)]
public void TestAcceptedCharacters(string input, bool expectedIsValid)
{
var isValid = Regex.IsMatch(input, _pattern);
Expand Down

0 comments on commit 846642a

Please sign in to comment.