Add phone number validation for advanced envelopes

Enforced phone number validation for `AdvancedSignature` envelopes:
- Introduced `CreateEnvelopeCommandValidator` to ensure receivers have non-empty phone numbers for advanced signatures.
- Updated `CreateEnvelopeWizardPopup.razor` to dynamically adjust phone number placeholder text and validate input.
- Added `ValidatePhoneNumber` method and integrated validation into the wizard's state management.
- Introduced `IsAdvancedSignatureSelected` helper property for conditional logic.
- Enhanced UI to reflect phone number requirements for advanced signatures.

Added a test case in `CreateEnvelopeCommandTests.cs` to verify that creating an advanced signature envelope without a phone number throws a `BadRequestException`.
This commit is contained in:
2026-11-30 16:52:29 +01:00
parent 402100a526
commit 58a162b84a
3 changed files with 77 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
using EnvelopeGenerator.Application.Envelopes.Commands;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Domain.Constants;
using DigitalData.Core.Exceptions;
using Microsoft.Extensions.DependencyInjection;
namespace EnvelopeGenerator.Tests.Application;
@@ -74,4 +76,27 @@ public class CreateEnvelopeCommandTests : TestBase
Assert.That(envelopeReceiver, Is.Not.Null);
Assert.That(envelopeReceiver!.PhoneNumber, Is.EqualTo(phoneNumber));
}
[Test]
public void CreateEnvelope_ShouldRequireReceiverPhoneNumber_ForAdvancedSignature()
{
var command = new CreateEnvelopeCommand
{
Type = EnvelopeType.AdvancedSignature,
Title = "Test Envelope",
Message = "Test Message",
UseSQLExecutor = false,
Document = new CreateEnvelopeDocumentDto(this.CreatePdfAsBase64()),
Receivers =
[
new CreateEnvelopeReceiverDto(
EmailAddress: this.Internet.Email(),
Name: this.Name.FullName(),
PhoneNumber: null,
Fields: [new CreateEnvelopeFieldDto(X: 1.0, Y: 1.0, Page: 1)])
]
}.WithAuth(User.Id);
Assert.ThrowsAsync<BadRequestException>(async () => await Mediator.Send(command));
}
}