在 C# 中是否有像 python's voluptuous 这样的数据验证 nuget 库?

Is there any data validation nuget library like python's voluptuous in C#?

为了数据验证,Python 编码人员经常会使用这个名为 Voluptuous 的库。是一个很棒的库,可以在代码中进一步处理数据之前验证数据。

我们可以在 C# 中使用任何等效的 NuGet 库吗?

下面是关于如何在 python

中使用性感的 python 片段
from voluptuous import Required, All, Length, Range
schema = Schema({
   Required('q'): All(str, Length(min=1)),
   Required('per_page', default=5): All(int, Range(min=1, max=20)), 'page': All(int, Range(min=0))
})

我不确定它与 Voluptuous 的匹配程度如何(我根本不是 Python 的用户),但 FluentValidation 是我喜欢并经常使用的库。它非常灵活,到目前为止很容易满足我的需求。

还有使用本机数据注释的选项,但这不太灵活,并且根据我个人的喜好将事物耦合得太紧密。我只在极少数情况下使用这些。