Skip to content

Commit d83cb46

Browse files
authored
Merge pull request #3 from LazZiya/vNext
V next
2 parents 7fce79e + 4e3821c commit d83cb46

12 files changed

Lines changed: 1126 additions & 48 deletions
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
namespace XLocalizer.DataAnnotations
2+
{
3+
/// <summary>
4+
/// Original messages obtained from <a href="https://github.com/dotnet/corefx/blob/master/src/System.ComponentModel.Annotations/src/Resources/Strings.resx"/>
5+
/// </summary>
6+
public class DefaultDataAnnotationsErrorMessagesProvider : IDataAnnotationsMessagesProvider
7+
{
8+
string IDataAnnotationsMessagesProvider.ArgumentIsNullOrWhitespace => "The argument '{0}' cannot be null, empty or contain only whitespace.";
9+
10+
string IDataAnnotationsMessagesProvider.AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties => "The associated metadata type for type '{0}' contains the following unknown properties or fields: {1}. Please make sure that the names of these members match the names of the properties on the main type.";
11+
12+
string IDataAnnotationsMessagesProvider.AttributeStore_Unknown_Property => "The type '{0}' does not contain a public property named '{1}'.";
13+
14+
string IDataAnnotationsMessagesProvider.Common_PropertyNotFound => "The property {0}.{1} could not be found.";
15+
16+
string IDataAnnotationsMessagesProvider.CompareAttribute_MustMatch => "'{0}' and '{1}' do not match.";
17+
18+
string IDataAnnotationsMessagesProvider.CompareAttribute_UnknownProperty => "Could not find a property named {0}.";
19+
20+
string IDataAnnotationsMessagesProvider.CreditCardAttribute_Invalid => "The {0} field is not a valid credit card number.";
21+
22+
string IDataAnnotationsMessagesProvider.CustomValidationAttribute_Type_Conversion_Failed => "Could not convert the value of type '{0}' to '{1}' as expected by method {2}.{3}.";
23+
24+
string IDataAnnotationsMessagesProvider.CustomValidationAttribute_Type_Must_Be_Public => "The custom validation type '{0}' must be public.";
25+
26+
string IDataAnnotationsMessagesProvider.CustomValidationAttribute_ValidationError => "{0} is not valid.";
27+
28+
string IDataAnnotationsMessagesProvider.DataTypeAttribute_EmptyDataTypeString => "The custom DataType string cannot be null or empty.";
29+
30+
string IDataAnnotationsMessagesProvider.DisplayAttribute_PropertyNotSet => "The {0} property has not been set. Use the {1} method to get the value.";
31+
32+
string IDataAnnotationsMessagesProvider.EmailAddressAttribute_Invalid => "The {0} field is not a valid e-mail address.";
33+
34+
string IDataAnnotationsMessagesProvider.EnumDataTypeAttribute_TypeCannotBeNull => "The type provided for EnumDataTypeAttribute cannot be null.";
35+
36+
string IDataAnnotationsMessagesProvider.EnumDataTypeAttribute_TypeNeedsToBeAnEnum => "The type '{0}' needs to represent an enumeration type.";
37+
38+
string IDataAnnotationsMessagesProvider.FileExtensionsAttribute_Invalid => "The {0} field only accepts files with the following extensions: {1}";
39+
40+
string IDataAnnotationsMessagesProvider.LengthAttribute_InvalidValueType => "The field of type {0} must be a string, array or ICollection type.";
41+
42+
string IDataAnnotationsMessagesProvider.MaxLengthAttribute_InvalidMaxLength => "MaxLengthAttribute must have a Length value that is greater than zero. Use MaxLength() without parameters to indicate that the string or array can have the maximum allowable length.";
43+
44+
string IDataAnnotationsMessagesProvider.MaxLengthAttribute_ValidationError => "The field {0} must be a string or array type with a maximum length of '{1}'.";
45+
46+
string IDataAnnotationsMessagesProvider.MetadataTypeAttribute_TypeCannotBeNull => "MetadataClassType cannot be null.";
47+
48+
string IDataAnnotationsMessagesProvider.MinLengthAttribute_InvalidMinLength => "MinLengthAttribute must have a Length value that is zero or greater.";
49+
50+
string IDataAnnotationsMessagesProvider.MinLengthAttribute_ValidationError => "The field {0} must be a string or array type with a minimum length of '{1}'.";
51+
52+
string IDataAnnotationsMessagesProvider.PhoneAttribute_Invalid => "The {0} field is not a valid phone number.";
53+
54+
string IDataAnnotationsMessagesProvider.RangeAttribute_ArbitraryTypeNotIComparable => "The type {0} must implement {1}.";
55+
56+
string IDataAnnotationsMessagesProvider.RangeAttribute_MinGreaterThanMax => "The maximum value '{0}' must be greater than or equal to the minimum value '{1}'.";
57+
58+
string IDataAnnotationsMessagesProvider.RangeAttribute_Must_Set_Min_And_Max => "The minimum and maximum values must be set.";
59+
60+
string IDataAnnotationsMessagesProvider.RangeAttribute_Must_Set_Operand_Type => "The OperandType must be set when strings are used for minimum and maximum values.";
61+
62+
string IDataAnnotationsMessagesProvider.RangeAttribute_ValidationError => "The field {0} must be between {1} and {2}.";
63+
64+
string IDataAnnotationsMessagesProvider.RegexAttribute_ValidationError => "The field {0} must match the regular expression '{1}'.";
65+
66+
string IDataAnnotationsMessagesProvider.RegularExpressionAttribute_Empty_Pattern => "The pattern must be set to a valid regular expression.";
67+
68+
string IDataAnnotationsMessagesProvider.RequiredAttribute_ValidationError => "The {0} field is required.";
69+
70+
string IDataAnnotationsMessagesProvider.StringLengthAttribute_InvalidMaxLength => "The maximum length must be a nonnegative integer.";
71+
72+
string IDataAnnotationsMessagesProvider.StringLengthAttribute_ValidationError => "The field {0} must be a string with a maximum length of {1}.";
73+
74+
string IDataAnnotationsMessagesProvider.StringLengthAttribute_ValidationErrorIncludingMinimum => "The field {0} must be a string with a minimum length of {2} and a maximum length of {1}.";
75+
76+
77+
string IDataAnnotationsMessagesProvider.UIHintImplementation_ControlParameterKeyIsNotAString => "The key parameter at position {0} with value '{1}' is not a string. Every key control parameter must be a string.";
78+
79+
string IDataAnnotationsMessagesProvider.UIHintImplementation_ControlParameterKeyIsNull => "The key parameter at position {0} is null. Every key control parameter must be a string.";
80+
81+
string IDataAnnotationsMessagesProvider.UIHintImplementation_ControlParameterKeyOccursMoreThanOnce => "The key parameter at position {0} with value '{1}' occurs more than once.";
82+
83+
string IDataAnnotationsMessagesProvider.UIHintImplementation_NeedEvenNumberOfControlParameters => "The number of control parameters must be even.";
84+
85+
string IDataAnnotationsMessagesProvider.UrlAttribute_Invalid => "The {0} field is not a valid fully-qualified http, https, or ftp URL.";
86+
87+
string IDataAnnotationsMessagesProvider.ValidationAttribute_Cannot_Set_ErrorMessage_And_Resource => "Either ErrorMessageString or ErrorMessageResourceName must be set, but not both.";
88+
89+
string IDataAnnotationsMessagesProvider.ValidationAttribute_IsValid_NotImplemented => "IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).";
90+
91+
string IDataAnnotationsMessagesProvider.ValidationAttribute_NeedBothResourceTypeAndResourceName => "Both ErrorMessageResourceType and ErrorMessageResourceName need to be set on this attribute.";
92+
93+
string IDataAnnotationsMessagesProvider.ValidationAttribute_ResourcePropertyNotStringType => "The property '{0}' on resource type '{1}' is not a string type.";
94+
95+
string IDataAnnotationsMessagesProvider.ValidationAttribute_ResourceTypeDoesNotHaveProperty => "The resource type '{0}' does not have an accessible static property named '{1}'.";
96+
97+
string IDataAnnotationsMessagesProvider.ValidationAttribute_ValidationError => "The field {0} is invalid.";
98+
99+
string IDataAnnotationsMessagesProvider.Validator_InstanceMustMatchValidationContextInstance => "The instance provided must match the ObjectInstance on the ValidationContext supplied.";
100+
101+
string IDataAnnotationsMessagesProvider.Validator_Property_Value_Wrong_Type => "The value for property '{0}' must be of type '{1}'.";
102+
}
103+
}
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
namespace XLocalizer.DataAnnotations
2+
{
3+
/// <summary>
4+
/// Interface to provide custom default data annotation error messages.
5+
/// Messages can be provided in any culture, so user can provide localized error messages here,
6+
/// but the default request culture in startup must be configured same as messages culture.
7+
/// </summary>
8+
public interface IDataAnnotationsMessagesProvider
9+
{
10+
/// <summary>
11+
/// The argument '{0}' cannot be null, empty or contain only whitespace.
12+
/// </summary>
13+
string ArgumentIsNullOrWhitespace { get; }
14+
15+
/// <summary>
16+
/// The associated metadata type for type '{0}' contains the following unknown properties or fields: {1}. Please make sure that the names of these members match the names of the properties on the main type.
17+
/// </summary>
18+
string AssociatedMetadataTypeTypeDescriptor_MetadataTypeContainsUnknownProperties { get; }
19+
20+
/// <summary>
21+
/// The type '{0}' does not contain a property named '{1}'.
22+
/// </summary>
23+
string AttributeStore_Unknown_Property { get; }
24+
25+
/// <summary>
26+
/// The property {0}.{1} could not be found.
27+
/// </summary>
28+
string Common_PropertyNotFound { get; }
29+
30+
/// <summary>
31+
/// '{0}' and '{1}' do not match.
32+
/// </summary>
33+
string CompareAttribute_MustMatch { get; }
34+
35+
/// <summary>
36+
/// Could not find a property named {0}.
37+
/// </summary>
38+
string CompareAttribute_UnknownProperty { get; }
39+
40+
/// <summary>
41+
/// The {0} field is not a valid credit card number.
42+
/// </summary>
43+
string CreditCardAttribute_Invalid { get; }
44+
45+
/// <summary>
46+
/// Could not convert the value of type '{0}' to '{1}' as expected by method {2}.{3}.
47+
/// </summary>
48+
string CustomValidationAttribute_Type_Conversion_Failed { get; }
49+
50+
/// <summary>
51+
/// The custom validation type '{0}' must be public.
52+
/// </summary>
53+
string CustomValidationAttribute_Type_Must_Be_Public { get; }
54+
55+
/// <summary>
56+
/// {0} is not valid.
57+
/// </summary>
58+
string CustomValidationAttribute_ValidationError { get; }
59+
60+
/// <summary>
61+
/// The custom DataType string cannot be null or empty.
62+
/// </summary>
63+
string DataTypeAttribute_EmptyDataTypeString { get; }
64+
65+
/// <summary>
66+
/// The {0} property has not been set. Use the {1} method to get the value.
67+
/// </summary>
68+
string DisplayAttribute_PropertyNotSet { get; }
69+
70+
/// <summary>
71+
/// The {0} field is not a valid e-mail address.
72+
/// </summary>
73+
string EmailAddressAttribute_Invalid { get; }
74+
75+
/// <summary>
76+
/// The type provided for EnumDataTypeAttribute cannot be null.
77+
/// </summary>
78+
string EnumDataTypeAttribute_TypeCannotBeNull { get; }
79+
80+
/// <summary>
81+
/// The type '{0}' needs to represent an enumeration type.
82+
/// </summary>
83+
string EnumDataTypeAttribute_TypeNeedsToBeAnEnum { get; }
84+
85+
/// <summary>
86+
/// The {0} field only accepts files with the following extensions: {1}
87+
/// </summary>
88+
string FileExtensionsAttribute_Invalid { get; }
89+
90+
/// <summary>
91+
/// The field of type {0} must be a string, array or ICollection type.
92+
/// </summary>
93+
string LengthAttribute_InvalidValueType { get; }
94+
95+
96+
/// <summary>
97+
/// MaxLengthAttribute must have a Length value that is greater than zero. Use MaxLength() without parameters to indicate that the string or array can have the maximum allowable length.
98+
/// </summary>
99+
string MaxLengthAttribute_InvalidMaxLength { get; }
100+
101+
/// <summary>
102+
/// The field {0} must be a string or array type with a maximum length of '{1}'.
103+
/// </summary>
104+
string MaxLengthAttribute_ValidationError { get; }
105+
106+
/// <summary>
107+
/// MetadataClassType cannot be null.
108+
/// </summary>
109+
string MetadataTypeAttribute_TypeCannotBeNull { get; }
110+
111+
/// <summary>
112+
/// MinLengthAttribute must have a Length value that is zero or greater.
113+
/// </summary>
114+
string MinLengthAttribute_InvalidMinLength { get; }
115+
116+
/// <summary>
117+
/// The field {0} must be a string or array type with a minimum length of '{1}'.
118+
/// </summary>
119+
string MinLengthAttribute_ValidationError { get; }
120+
121+
/// <summary>
122+
/// The {0} field is not a valid phone number.
123+
/// </summary>
124+
string PhoneAttribute_Invalid { get; }
125+
126+
/// <summary>
127+
/// The type {0} must implement {1}.
128+
/// </summary>
129+
string RangeAttribute_ArbitraryTypeNotIComparable { get; }
130+
131+
/// <summary>
132+
/// The maximum value '{0}' must be greater than or equal to the minimum value '{1}'.
133+
/// </summary>
134+
string RangeAttribute_MinGreaterThanMax { get; }
135+
136+
/// <summary>
137+
/// The minimum and maximum values must be set.
138+
/// </summary>
139+
string RangeAttribute_Must_Set_Min_And_Max { get; }
140+
141+
/// <summary>
142+
/// The OperandType must be set when strings are used for minimum and maximum values.
143+
/// </summary>
144+
string RangeAttribute_Must_Set_Operand_Type { get; }
145+
146+
/// <summary>
147+
/// The field {0} must be between {1} and {2}.
148+
/// </summary>
149+
string RangeAttribute_ValidationError { get; }
150+
151+
/// <summary>
152+
/// The field {0} must match the regular expression '{1}'.
153+
/// </summary>
154+
string RegexAttribute_ValidationError { get; }
155+
156+
/// <summary>
157+
/// The pattern must be set to a valid regular expression.
158+
/// </summary>
159+
string RegularExpressionAttribute_Empty_Pattern { get; }
160+
161+
/// <summary>
162+
/// The {0} field is required.
163+
/// </summary>
164+
string RequiredAttribute_ValidationError { get; }
165+
166+
/// <summary>
167+
/// The maximum length must be a nonnegative integer.
168+
/// </summary>
169+
string StringLengthAttribute_InvalidMaxLength { get; }
170+
171+
/// <summary>
172+
/// The field {0} must be a string with a maximum length of {1}.
173+
/// </summary>
174+
string StringLengthAttribute_ValidationError { get; }
175+
176+
/// <summary>
177+
/// The field {0} must be a string with a minimum length of {2} and a maximum length of {1}.
178+
/// </summary>
179+
string StringLengthAttribute_ValidationErrorIncludingMinimum { get; }
180+
181+
/// <summary>
182+
/// The key parameter at position {0} with value '{1}' is not a string. Every key control parameter must be a string.
183+
/// </summary>
184+
string UIHintImplementation_ControlParameterKeyIsNotAString { get; }
185+
186+
/// <summary>
187+
/// The key parameter at position {0} is null. Every key control parameter must be a string.
188+
/// </summary>
189+
string UIHintImplementation_ControlParameterKeyIsNull { get; }
190+
191+
/// <summary>
192+
/// The key parameter at position {0} with value '{1}' occurs more than once.
193+
/// </summary>
194+
string UIHintImplementation_ControlParameterKeyOccursMoreThanOnce { get; }
195+
196+
/// <summary>
197+
/// The number of control parameters must be even.
198+
/// </summary>
199+
string UIHintImplementation_NeedEvenNumberOfControlParameters { get; }
200+
201+
/// <summary>
202+
/// The {0} field is not a valid fully-qualified http, https, or ftp URL.
203+
/// </summary>
204+
string UrlAttribute_Invalid { get; }
205+
206+
/// <summary>
207+
/// Either ErrorMessageString or ErrorMessageResourceName must be set, but not both.
208+
/// </summary>
209+
string ValidationAttribute_Cannot_Set_ErrorMessage_And_Resource { get; }
210+
211+
/// <summary>
212+
/// IsValid(object value) has not been implemented by this class. The preferred entry point is GetValidationResult() and classes should override IsValid(object value, ValidationContext context).
213+
/// </summary>
214+
string ValidationAttribute_IsValid_NotImplemented { get; }
215+
216+
/// <summary>
217+
/// Both ErrorMessageResourceType and ErrorMessageResourceName need to be set on this attribute.
218+
/// </summary>
219+
string ValidationAttribute_NeedBothResourceTypeAndResourceName { get; }
220+
221+
/// <summary>
222+
/// The property '{0}' on resource type '{1}' is not a string type.
223+
/// </summary>
224+
string ValidationAttribute_ResourcePropertyNotStringType { get; }
225+
226+
/// <summary>
227+
/// The resource type '{0}' does not have an accessible static property named '{1}'.
228+
/// </summary>
229+
string ValidationAttribute_ResourceTypeDoesNotHaveProperty { get; }
230+
231+
/// <summary>
232+
/// The field {0} is invalid.
233+
/// </summary>
234+
string ValidationAttribute_ValidationError { get; }
235+
236+
/// <summary>
237+
/// The instance provided must match the ObjectInstance on the ValidationContext supplied.
238+
/// </summary>
239+
string Validator_InstanceMustMatchValidationContextInstance { get; }
240+
241+
/// <summary>
242+
/// The value for property '{0}' must be of type '{1}'.
243+
/// </summary>
244+
string Validator_Property_Value_Wrong_Type { get; }
245+
}
246+
}

0 commit comments

Comments
 (0)