Browse Source

Implement MaxLength to PaymentRequest properties

pull/69/head
enisn 5 years ago
parent
commit
6a66abf094
  1. 4
      modules/payment/src/Payment.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs
  2. 6
      modules/payment/src/Payment.Domain/PaymentRequests/PaymentRequest.cs

4
modules/payment/src/Payment.Application.Contracts/PaymentRequests/PaymentRequestCreationDto.cs

@ -1,16 +1,20 @@
using JetBrains.Annotations;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Validation;
namespace Payment.PaymentRequests
{
public class PaymentRequestCreationDto : ExtensibleObject
{
[DynamicMaxLength(typeof(PaymentRequestConsts), nameof(PaymentRequestConsts.MaxCustomerIdLength))]
public string CustomerId { get; set; }
[DynamicMaxLength(typeof(PaymentRequestConsts), nameof(PaymentRequestConsts.MaxProductIdLength))]
public string ProductId { get; set; }
[Required]
[DynamicMaxLength(typeof(PaymentRequestConsts), nameof(PaymentRequestConsts.MaxProductNameLength))]
public string ProductName { get; set; }
public decimal Price { get; set; }

6
modules/payment/src/Payment.Domain/PaymentRequests/PaymentRequest.cs

@ -40,9 +40,9 @@ namespace Payment.PaymentRequests
[NotNull] string currency)
: base(id)
{
CustomerId = customerId;
ProductId = productId;
ProductName = Check.NotNullOrWhiteSpace(productName, nameof(productName));
CustomerId = Check.NotNullOrEmpty(customerId, nameof(customerId), maxLength: PaymentRequestConsts.MaxCustomerIdLength);
ProductId = Check.NotNullOrEmpty(productId, nameof(productId), maxLength: PaymentRequestConsts.MaxProductIdLength);
ProductName = Check.NotNullOrWhiteSpace(productName, nameof(productName), maxLength: PaymentRequestConsts.MaxProductNameLength);
Price = price;
Currency = currency;
}

Loading…
Cancel
Save