Skip to content

Commit 25d83ed

Browse files
committed
Added public DictionaryKey property to all attributes
* Updated readme.md
1 parent 4ad2a31 commit 25d83ed

File tree

92 files changed

+3218
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3218
-382
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,10 @@ paket-files/
258258

259259
# Python Tools for Visual Studio (PTVS)
260260
__pycache__/
261-
*.pyc
261+
*.pyc
262+
263+
# UmbracoCms
264+
umbraco/
265+
umbraco_client/
266+
App_Data/
267+
App_Code

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ public string Username { get; set; }
150150

151151
Example:
152152
```c#
153-
[UmbracoRequired]
154-
[UmbracoEmailAddress]
155-
[UmbracoDisplayName(nameof(Email))]
156-
[DataType(DataType.EmailAddress)]
153+
[UmbracoEmailAddress(DictionaryKey = "MyCustomKey")]
157154
public string Email { get; set; }
158155
```
159156

@@ -165,7 +162,7 @@ public string Email { get; set; }
165162

166163
Example:
167164
```C#
168-
[UmbracoMinLength(20)]
165+
[UmbracoMinLength(20, DictionaryKey = "MyCustomKey")]
169166
property string MyProperty { get; set; }
170167
```
171168

@@ -177,7 +174,7 @@ property string MyProperty { get; set; }
177174

178175
Example:
179176
```C#
180-
[UmbracoMaxLength(120)]
177+
[UmbracoMaxLength(120, DictionaryKey = "MyCustomKey")]
181178
property string MyProperty { get; set; }
182179
```
183180

@@ -190,7 +187,7 @@ property string MyProperty { get; set; }
190187

191188
Example:
192189
```C#
193-
[UmbracoStringLength(120, MinimumLength = 30)]
190+
[UmbracoStringLength(120, MinimumLength = 30, DictionaryKey = "MyCustomKey")]
194191
property string Message { get; set; }
195192
```
196193

@@ -201,7 +198,7 @@ property string Message { get; set; }
201198

202199
Example:
203200
```C#
204-
[MustBeTrue]
201+
[UmbracoMustBeTrue(DictionaryKey = "MyCustomKey")]
205202
property boool Consent { get; set; }
206203
```
207204

@@ -215,7 +212,11 @@ property boool Consent { get; set; }
215212

216213
Example:
217214
```C#
218-
[UmbracoPassword]
215+
[UmbracoPassword(DictionaryKey = "CustomPasswordKey",
216+
MinPasswordLengthDictionaryKey = "CustomMinPasswordLengthKey",
217+
MinNonAlphanumericCharactersDictionaryKey = "MyCustomMinNonAlphanumericCharactersKey",
218+
PasswordStrengthDictionaryKey = "MyCustomPasswordStrengtKey",
219+
PasswordStrengthRegexTimeout = 360)]
219220
property string Password { get; set; }
220221
```
221222

@@ -225,14 +226,25 @@ There are no default keys for this attribute, since each regex validation is uni
225226

226227
Example:
227228
```C#
228-
[UmbracoRegularExpression()]
229+
[UmbracoRegularExpression(DictionaryKey = "MyCustomRegexKey")]
229230
property string Password { get; set; }
230231
```
231232

232233
### UmbracoRequired
233234

234235
Example:
235236
```C#
236-
[UmbracoRequired]
237+
[UmbracoRequired(DictionaryKey = "MyCustomRequiredKey")]
238+
property string MyProperty { get; set; }
239+
```
240+
241+
## Custom dictionary keys
242+
Each Attribute, has a public property `DictionaryKey` which can be set like this:
243+
```
244+
[UmbracoReguired(DictionaryKey = "MyCustomKey")]
245+
[UmbracoRegularExpression(DictionaryKey = "MyCustomRegexKey")]
246+
[UmbracoRegularExpression(DictionaryKey = "MyCustomRegexKey")]
237247
property string MyProperty { get; set; }
238-
```
248+
```
249+
250+
Not setting a custom key, will fallback to the default dictionary key.

src/Our.Umbraco.DataAnnotations.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28010.2048
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29403.142
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.DataAnnotations", "Our.Umbraco.DataAnnotations\Our.Umbraco.DataAnnotations.csproj", "{C808941C-0685-4F06-80CE-81AE4E8B82E3}"
77
EndProject
@@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{041121B7
1919
Our.Umbraco.DataAnnotations\Our.Umbraco.DataAnnotations.nuspec = Our.Umbraco.DataAnnotations\Our.Umbraco.DataAnnotations.nuspec
2020
EndProjectSection
2121
EndProject
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UmbracoCms", "UmbracoCms\UmbracoCms.csproj", "{03A5C03C-2BF9-4EF5-9473-867F2D31BFC6}"
23+
EndProject
2224
Global
2325
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2426
Debug|Any CPU = Debug|Any CPU
@@ -29,6 +31,10 @@ Global
2931
{C808941C-0685-4F06-80CE-81AE4E8B82E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
3032
{C808941C-0685-4F06-80CE-81AE4E8B82E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
3133
{C808941C-0685-4F06-80CE-81AE4E8B82E3}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{03A5C03C-2BF9-4EF5-9473-867F2D31BFC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{03A5C03C-2BF9-4EF5-9473-867F2D31BFC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{03A5C03C-2BF9-4EF5-9473-867F2D31BFC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{03A5C03C-2BF9-4EF5-9473-867F2D31BFC6}.Release|Any CPU.Build.0 = Release|Any CPU
3238
EndGlobalSection
3339
GlobalSection(SolutionProperties) = preSolution
3440
HideSolutionNode = FALSE

src/Our.Umbraco.DataAnnotations/ConditionalValidationAttributes.cs

Lines changed: 0 additions & 155 deletions
This file was deleted.

src/Our.Umbraco.DataAnnotations/CreateDictionaryKeys.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Our.Umbraco.DataAnnotations.Interfaces
8+
{
9+
public interface IUmbracoValidationAttribute
10+
{
11+
string DictionaryKey { get; set; }
12+
}
13+
}

src/Our.Umbraco.DataAnnotations/Our.Umbraco.DataAnnotations.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
<ItemGroup>
222222
<Compile Include="Conditionals\ConditionalValidationAttributes.cs" />
223223
<Compile Include="Constants.cs" />
224+
<Compile Include="Interfaces\IUmbracoValidationAttribute.cs" />
224225
<Compile Include="Migrations\CreateDictionaryKeys.cs" />
225226
<Compile Include="Migrations\Runner.cs" />
226227
<Compile Include="Properties\AssemblyInfo.cs" />

0 commit comments

Comments
 (0)