【发布时间】:2021-11-13 17:13:40
【问题描述】:
我正在使用这个 API https://developer-eu.elavon.com/docs/opayo/spec/api-reference-0#operation/createCi。
在这个链接中,他们说
cardholderName
required
string <= 45 characters
The name of the card holder
cardNumber
required
string <= 16 characters
The number of the card
expiryDate
required
string 4 characters
The expiry date of the card in MMYY format
securityCode
required
string [ 3 .. 4 ] characters
The card security code, also known as CV2, CVV, or CVC. This is used in CV2 checks.
我为字符串长度验证添加了
[Required]
[StringLength(45)]
public string CardholderName { get; set; }
在此 API 中,他们验证 securityCode 是 POST 请求所需的字符串 [3 .. 4 ] 个字符。
如何添加验证
securityCode required string [ 3 .. 4 ] characters?
【问题讨论】:
-
“为此添加验证”到底是什么意思?
-
我已经添加了更多。请检查
-
StringLengthAttribute可以指定最小值和最大值。 -
[RegularExpression("^(0[1-9])|(1[0-2])2[0-9]$")]- 我们接受一年中的任何月份 [20]20..29
标签: c# asp.net-core validation