c# - 如何验证 C# 中的 Picture 子句?

标签 c# validation cobol edi

我正在使用 EDI.Net核包。在他们的Readme.md文件,他们在谈论“图片条款”:

The Picture Clause is taken from COBOL laguage and the way it handles expressing numeric and alphanumric data types.

我的模型是这样的:

[EdiMessage]
public class DeliveryNote
{
    [EdiValue("X(9)", Path = "RFF/0/1")]
    public string Identification { get; set; }
}

我希望使用此 EdiValue-DataAttribute ( source code ) 来验证我的模型。看起来他们已经在以某种方式在内部解析那些 Picture 子句。

我还不知道如何验证我的模型。第一个明显的想法是使用 .NET 验证类(ValidatorValidationContext,...):

var deliveryNote = new DeliveryNote();
deliveryNote.Identification = null;

var context = new ValidationContext(deliveryNote, serviceProvider: null, items: null);
var validationResults = new List<ValidationResult>();
bool isValid = Validator.TryValidateObject(deliveryNote, context, validationResults, true);

似乎没有任何东西经过验证。

我的错误在哪里?你能验证那些图片条款吗?如果这个 Picture 子句支持不是为了验证,它们的目的是什么?

最佳答案

Where is my mistake? Can you validate those Picture clauses? If this Picture clause support is not for validation, what is their purpose?

图片子句描述数据元素的格式。您不验证图片子句,但您可以验证数据元素的内容——它的值。您使用用户文档中的图片子句和其他信息来确定验证标准。

A previous post触及什么是图片问题。该帖子还提供了一个 link一个带有数据元素描述的段示例。

关于c# - 如何验证 C# 中的 Picture 子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56292866/

相关文章:

file - AIX 文件访问上的 IBM COBOL

c# - 在将字符串从一种形式传递到另一种形式时调用函数

javascript - 使用 jquery 验证动态输入字段

c# - IDateErrorInfo Multi Validation.ErrorTemplate

validation - 在 CakePHP 验证中,如果我有另一个规则(如 alphaNumeric)且 allowedEmpty 为 false,我是否需要 notEmpty 规则?

cobol - 从压缩十进制字段中分割数字

cobol - 如何在cobol中清除屏幕并将光标位置设置到屏幕末尾

c# - 对扩展方法的调用不明确

c# - NHibernate - session 单例 C#

c# - 在 c#.net 中设置饼图中的颜色