enums

GetFields method to get enum values

拈花ヽ惹草 提交于 2020-08-27 10:57:27
问题 I have noticed that when calling GetFields() on enum type, I'm getting an extra fields with type int32. where did it come from?? When I call the other overload (GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) ) , it returns the desired fields. is that means that the enum's fields are not Public ? thanks 回答1: Reflector IL Spy can explain this. Take a look at a decompiled enum and you will see something that looks like this: .class public auto ansi

Mongoose Model Custom Error Message for Enums

这一生的挚爱 提交于 2020-08-27 05:43:17
问题 I would like to customize the validation messages that my Mongoose Models produce. I tend to NOT put my validations (e.g. required) on the schema object directly because there is no freedom to have custom error messages. e.g. sourceAccountId: { type: Schema.ObjectId, require: true, ref: 'Account' } instead I do the following. sourceAccountId: { type: Schema.ObjectId, ref: 'Account' } ConnectionRequestSchema.path('sourceAccountId').required(true, 'Source Account is required.'); I have been

Mongoose Model Custom Error Message for Enums

末鹿安然 提交于 2020-08-27 05:42:08
问题 I would like to customize the validation messages that my Mongoose Models produce. I tend to NOT put my validations (e.g. required) on the schema object directly because there is no freedom to have custom error messages. e.g. sourceAccountId: { type: Schema.ObjectId, require: true, ref: 'Account' } instead I do the following. sourceAccountId: { type: Schema.ObjectId, ref: 'Account' } ConnectionRequestSchema.path('sourceAccountId').required(true, 'Source Account is required.'); I have been