我应该如何命名一个描述字段是隐藏、可选还是必填的枚举?

发布于 2024-08-15 20:18:37 字数 343 浏览 2 评论 0原文

我有一个带有一堆字段的控件,我希望用户能够配置它们。

我最初有这个:

    public bool Phone1Visible;
    public bool Phone1Required;

然后意识到我不想处理必须再次验证隐藏的必填字段,所以我想出了这个:

public enum YOUR_NAME_HERE
{
    Hidden,
    Optional,
    Required
}

你会命名这个枚举吗?我在想“FieldCriticality”,但这听起来有点罗嗦。

欢迎提出建议。

I have a control with a bunch of fields that I want a user to be able to configure.

I originally had this:

    public bool Phone1Visible;
    public bool Phone1Required;

Then realized that I didn't want to deal with having to validate again hidden required fields, so I came up with this:

public enum YOUR_NAME_HERE
{
    Hidden,
    Optional,
    Required
}

What would you name this enum? I was thinking "FieldCriticality", but that sounds a little wordy.

Suggestions welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

唱一曲作罢 2024-08-22 20:18:38

我会使用 FieldState。

I would use FieldState.

草莓味的萝莉 2024-08-22 20:18:38

FieldMode 怎么样?我认为“模式”有助于传达这与字段的或用户当前与其交互的方式无关。

How about FieldMode? I think “mode” helps convey that this isn't to do with the value of the field, or how the user is currently interacting with it.

那片花海 2024-08-22 20:18:38

我将使用 FieldValidation 作为您希望如何使用此枚举的描述性标题。

I would use FieldValidation, as a descriptive title of how you wish to use this enum.

浊酒尽余欢 2024-08-22 20:18:38

我会选择 FieldType

public enum FieldType
{
    Hidden,
    Optional,
    Required
}

I would go by FieldType

public enum FieldType
{
    Hidden,
    Optional,
    Required
}
听风吹 2024-08-22 20:18:38

我会使用 FieldProperty 或 FieldAttribute

I would use FieldProperty or FieldAttribute

征棹 2024-08-22 20:18:38

也许 FieldModifierFieldInteraction 适合您?

Maybe FieldModifier or FieldInteraction would suit you?

神回复 2024-08-22 20:18:38

状态

就这么简单。

然后你会得到

public Status Phone1Visible;
public Status Phone1Required;

看起来非常具有可读性和解释性的信息,特别是在使用 Intellisense 弹出时

Status

As simple as it gets.

Then you'd get

public Status Phone1Visible;
public Status Phone1Required;

which seems very readable and explanatory, expeciaally when popping up with Intellisense

流心雨 2024-08-22 20:18:38

我只是花了一些时间思考这个问题并最终得到:

public enum ValidationMode
{
    Optional,
    Required
}

因为最终我会使用这些信息进行验证。我觉得“FieldType”等建议更多地指的是字段内部类型(文本字段、复选框字段)。

I just spent a while thinking about this problem and ended up with:

public enum ValidationMode
{
    Optional,
    Required
}

because in the end I would use this information for validation. I feel that the suggestions such as "FieldType" refers more to the fields internal type (text field, checkbox field).

慕巷 2024-08-22 20:18:38

我经常将 InputPolicy 用于这样的枚举。

I often use InputPolicy for enums like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文