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

@@ -0,0 +1,19 @@
using EnvelopeGenerator.Domain.Constants;
using FluentValidation;
namespace EnvelopeGenerator.Application.Envelopes.Commands;
public sealed class CreateEnvelopeCommandValidator : AbstractValidator<CreateEnvelopeCommand>
{
public CreateEnvelopeCommandValidator()
{
When(
x => x.Type == EnvelopeType.AdvancedSignature,
() =>
{
RuleForEach(x => x.Receivers)
.Must(receiver => !string.IsNullOrWhiteSpace(receiver.PhoneNumber))
.WithMessage("PhoneNumber is required for advanced signature envelopes.");
});
}
}