diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..5a7d0cc --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,29 @@ + + + + net6.0 + . + umbraco plugin package + 2.0.0 + ZioTino + LICENSE.md + README.md + icon.png + https://github.com/ZioTino/Our.Umbraco.ValidationAttributes + git + enable + enable + + + + + + + + + true + true + true + snupkg + + diff --git a/src/App_Plugins/Our.Umbraco.ValidationAttributes/package.manifest b/src/App_Plugins/Our.Umbraco.ValidationAttributes/package.manifest deleted file mode 100644 index 7a73a41..0000000 --- a/src/App_Plugins/Our.Umbraco.ValidationAttributes/package.manifest +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/src/Components/ValidationAttributesComponent.cs b/src/Our.Umbraco.ValidationAttributes.Core/Components/ValidationAttributesComponent.cs similarity index 100% rename from src/Components/ValidationAttributesComponent.cs rename to src/Our.Umbraco.ValidationAttributes.Core/Components/ValidationAttributesComponent.cs diff --git a/src/Conditionals/ConditionalValidationAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/Conditionals/ConditionalValidationAttribute.cs similarity index 100% rename from src/Conditionals/ConditionalValidationAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/Conditionals/ConditionalValidationAttribute.cs diff --git a/src/Constants.cs b/src/Our.Umbraco.ValidationAttributes.Core/Constants.cs similarity index 100% rename from src/Constants.cs rename to src/Our.Umbraco.ValidationAttributes.Core/Constants.cs diff --git a/src/Helpers/AttributeHelper.cs b/src/Our.Umbraco.ValidationAttributes.Core/Helpers/AttributeHelper.cs similarity index 100% rename from src/Helpers/AttributeHelper.cs rename to src/Our.Umbraco.ValidationAttributes.Core/Helpers/AttributeHelper.cs diff --git a/src/Interfaces/IUmbracoValidationAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/Interfaces/IUmbracoValidationAttribute.cs similarity index 100% rename from src/Interfaces/IUmbracoValidationAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/Interfaces/IUmbracoValidationAttribute.cs diff --git a/src/Our.Umbraco.ValidationAttributes.Core/Our.Umbraco.ValidationAttributes.csproj b/src/Our.Umbraco.ValidationAttributes.Core/Our.Umbraco.ValidationAttributes.csproj new file mode 100644 index 0000000..a3369c8 --- /dev/null +++ b/src/Our.Umbraco.ValidationAttributes.Core/Our.Umbraco.ValidationAttributes.csproj @@ -0,0 +1,16 @@ + + + Our.Umbraco.ValidationAttributes + Our.Umbraco.ValidationAttributes + Umbraco.ValidationAttributes + [Umbraco v9] Contains validation attributes to decorate your classes, but using Umbraco Dictionary as the resource. + Our.Umbraco.ValidationAttributes + + + + + + + + + diff --git a/src/Services/ValidationAttributesService.cs b/src/Our.Umbraco.ValidationAttributes.Core/Services/ValidationAttributesService.cs similarity index 100% rename from src/Services/ValidationAttributesService.cs rename to src/Our.Umbraco.ValidationAttributes.Core/Services/ValidationAttributesService.cs diff --git a/src/UmbracoCompareAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoCompareAttribute.cs similarity index 100% rename from src/UmbracoCompareAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoCompareAttribute.cs diff --git a/src/UmbracoDisplayNameAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoDisplayNameAttribute.cs similarity index 100% rename from src/UmbracoDisplayNameAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoDisplayNameAttribute.cs diff --git a/src/UmbracoEmailAddressAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoEmailAddressAttribute.cs similarity index 100% rename from src/UmbracoEmailAddressAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoEmailAddressAttribute.cs diff --git a/src/UmbracoIFormFileExtensionsAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoIFormFileExtensionsAttribute.cs similarity index 95% rename from src/UmbracoIFormFileExtensionsAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoIFormFileExtensionsAttribute.cs index 02b7adf..bdfcb38 100644 --- a/src/UmbracoIFormFileExtensionsAttribute.cs +++ b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoIFormFileExtensionsAttribute.cs @@ -38,7 +38,7 @@ public void AddValidation(ClientModelValidationContext context) AttributeHelper.MergeAttribute(context.Attributes, "data-val-filetypes-types", string.Join(',', ValidFileTypes)); // input type="file" accept attribute - List validExtensions = new List(); + System.Collections.Generic.List validExtensions = new System.Collections.Generic.List(); foreach (string type in ValidFileTypes) { validExtensions.Add($".{type}"); diff --git a/src/UmbracoMaxFileSizeAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoMaxFileSizeAttribute.cs similarity index 100% rename from src/UmbracoMaxFileSizeAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoMaxFileSizeAttribute.cs diff --git a/src/UmbracoMaxLengthAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoMaxLengthAttribute.cs similarity index 100% rename from src/UmbracoMaxLengthAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoMaxLengthAttribute.cs diff --git a/src/UmbracoMinLengthAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoMinLengthAttribute.cs similarity index 100% rename from src/UmbracoMinLengthAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoMinLengthAttribute.cs diff --git a/src/UmbracoMustBeTrueAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoMustBeTrueAttribute.cs similarity index 100% rename from src/UmbracoMustBeTrueAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoMustBeTrueAttribute.cs diff --git a/src/UmbracoRangeAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoRangeAttribute.cs similarity index 100% rename from src/UmbracoRangeAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoRangeAttribute.cs diff --git a/src/UmbracoRegularExpressionAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoRegularExpressionAttribute.cs similarity index 100% rename from src/UmbracoRegularExpressionAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoRegularExpressionAttribute.cs diff --git a/src/UmbracoRemoteAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoRemoteAttribute.cs similarity index 100% rename from src/UmbracoRemoteAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoRemoteAttribute.cs diff --git a/src/UmbracoRequiredAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoRequiredAttribute.cs similarity index 100% rename from src/UmbracoRequiredAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoRequiredAttribute.cs diff --git a/src/UmbracoStringLengthAttribute.cs b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoStringLengthAttribute.cs similarity index 89% rename from src/UmbracoStringLengthAttribute.cs rename to src/Our.Umbraco.ValidationAttributes.Core/UmbracoStringLengthAttribute.cs index f68ba41..bf32e1f 100644 --- a/src/UmbracoStringLengthAttribute.cs +++ b/src/Our.Umbraco.ValidationAttributes.Core/UmbracoStringLengthAttribute.cs @@ -15,6 +15,11 @@ public sealed class UmbracoStringLengthAttribute : StringLengthAttribute, IClien public UmbracoStringLengthAttribute(int maximumLength) : base(maximumLength) {} + public UmbracoStringLengthAttribute(string dictionaryKey, int maximumLength) : base(maximumLength) + { + DictionaryKey = dictionaryKey; + } + public void AddValidation(ClientModelValidationContext context) { ErrorMessage = ValidationAttributesService.DictionaryValue(DictionaryKey); diff --git a/src/App_Plugins/Our.Umbraco.ValidationAttributes/Scripts/jquery.validation.custom.js b/src/Our.Umbraco.ValidationAttributes.StaticAssets/App_Plugins/Our.Umbraco.ValidationAttributes/Scripts/jquery.validation.custom.js similarity index 100% rename from src/App_Plugins/Our.Umbraco.ValidationAttributes/Scripts/jquery.validation.custom.js rename to src/Our.Umbraco.ValidationAttributes.StaticAssets/App_Plugins/Our.Umbraco.ValidationAttributes/Scripts/jquery.validation.custom.js diff --git a/src/Our.Umbraco.ValidationAttributes.StaticAssets/Our.Umbraco.ValidationAttributes.StaticAssets.csproj b/src/Our.Umbraco.ValidationAttributes.StaticAssets/Our.Umbraco.ValidationAttributes.StaticAssets.csproj new file mode 100644 index 0000000..fbd6139 --- /dev/null +++ b/src/Our.Umbraco.ValidationAttributes.StaticAssets/Our.Umbraco.ValidationAttributes.StaticAssets.csproj @@ -0,0 +1,18 @@ + + + Our.Umbraco.ValidationAttributes.StaticAssets + Our.Umbraco.ValidationAttributes.StaticAssets + Our.Umbraco.ValidationAttributes.StaticAssets + [Umbraco v9] Contains validation attributes to decorate your classes, but using Umbraco Dictionary as the resource. + umbraco plugin package + App_Plugins + true + Our.Umbraco.ValidationAttributes.StaticAssets + + + + + + + + diff --git a/src/Our.Umbraco.ValidationAttributes.StaticAssets/StaticAssetsBoot.cs b/src/Our.Umbraco.ValidationAttributes.StaticAssets/StaticAssetsBoot.cs new file mode 100644 index 0000000..bba59c4 --- /dev/null +++ b/src/Our.Umbraco.ValidationAttributes.StaticAssets/StaticAssetsBoot.cs @@ -0,0 +1,12 @@ +using Umbraco.Cms.Core.Composing; +using Umbraco.Cms.Core.DependencyInjection; + +namespace Our.Umbraco.ValidationAttributes.UI; + +public class StaticAssetsBoot : IComposer +{ + public void Compose(IUmbracoBuilder builder) + { + builder.AddValidationAttributesStaticAssets(); + } +} \ No newline at end of file diff --git a/src/Our.Umbraco.ValidationAttributes.StaticAssets/ValidationAttributesAssetManifestFilter.cs b/src/Our.Umbraco.ValidationAttributes.StaticAssets/ValidationAttributesAssetManifestFilter.cs new file mode 100644 index 0000000..bd687f8 --- /dev/null +++ b/src/Our.Umbraco.ValidationAttributes.StaticAssets/ValidationAttributesAssetManifestFilter.cs @@ -0,0 +1,28 @@ +using System.Diagnostics; +using Umbraco.Cms.Core.Manifest; + +namespace Our.Umbraco.ValidationAttributes.UI; + +internal class ValidationAttributesAssetManifestFilter : IManifestFilter +{ + public void Filter(List manifests) + { + var assembly = typeof(ValidationAttributesAssetManifestFilter).Assembly; + FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); + string version = fileVersionInfo.ProductVersion; + + manifests.Add(new PackageManifest + { + PackageName = "OurUmbracoValidationAttributes", + + BundleOptions = BundleOptions.None, + Scripts = new string[] + { + $"App_Plugins/Our.Umbraco.ValidationAttributes/scripts/jquery.validation.custom.js" + }, + Stylesheets = new string[] + { + } + }); + } +} \ No newline at end of file diff --git a/src/Our.Umbraco.ValidationAttributes.StaticAssets/ValidationAttributesStaticAssetsExtensions.cs b/src/Our.Umbraco.ValidationAttributes.StaticAssets/ValidationAttributesStaticAssetsExtensions.cs new file mode 100644 index 0000000..55b7566 --- /dev/null +++ b/src/Our.Umbraco.ValidationAttributes.StaticAssets/ValidationAttributesStaticAssetsExtensions.cs @@ -0,0 +1,18 @@ +using Umbraco.Cms.Core.DependencyInjection; + +namespace Our.Umbraco.ValidationAttributes.UI; + +public static class ValidationAttributesStaticAssetsExtensions +{ + public static IUmbracoBuilder AddValidationAttributesStaticAssets(this IUmbracoBuilder builder) + { + // don't add if the filter is already there . + if (builder.ManifestFilters().Has()) + return builder; + + // add the package manifest programatically. + builder.ManifestFilters().Append(); + + return builder; + } +} \ No newline at end of file diff --git a/src/Our.Umbraco.ValidationAttributes.csproj b/src/Our.Umbraco.ValidationAttributes.csproj deleted file mode 100644 index 9607b53..0000000 --- a/src/Our.Umbraco.ValidationAttributes.csproj +++ /dev/null @@ -1,41 +0,0 @@ - - - net5.0 - . - Our.Umbraco.ValidationAttributes - Our.Umbraco.ValidationAttributes - Umbraco.ValidationAttributes - [Umbraco v9] Contains validation attributes to decorate your classes, but using Umbraco Dictionary as the resource. - umbraco plugin package - 1.1.0 - ZioTino - Our.Umbraco.ValidationAttributes - LICENSE.md - README.md - icon.png - https://github.com/ZioTino/Our.Umbraco.ValidationAttributes - git - - - - - - - - - - - - - - - - true - Always - - - True - buildTransitive - - - diff --git a/src/Our.Umbraco.ValidationAttributes.sln b/src/Our.Umbraco.ValidationAttributes.sln new file mode 100644 index 0000000..b14a6d8 --- /dev/null +++ b/src/Our.Umbraco.ValidationAttributes.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.ValidationAttributes", "Our.Umbraco.ValidationAttributes.Core\Our.Umbraco.ValidationAttributes.csproj", "{3285A602-6540-44A8-AB6D-743B89F1BD40}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{EA678F62-05A8-4FFC-841A-D5FC59365513}" + ProjectSection(SolutionItems) = preProject + ..\LICENSE.md = ..\LICENSE.md + ..\assets\icon.png = ..\assets\icon.png + ..\docs\README.md = ..\docs\README.md + ..\docs\_config.yml = ..\docs\_config.yml + ..\Directory.Build.props = ..\Directory.Build.props + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.ValidationAttributes.StaticAssets", "Our.Umbraco.ValidationAttributes.StaticAssets\Our.Umbraco.ValidationAttributes.StaticAssets.csproj", "{A4E32C0B-C878-4A6F-BF96-D99E8A025091}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3285A602-6540-44A8-AB6D-743B89F1BD40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3285A602-6540-44A8-AB6D-743B89F1BD40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3285A602-6540-44A8-AB6D-743B89F1BD40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3285A602-6540-44A8-AB6D-743B89F1BD40}.Release|Any CPU.Build.0 = Release|Any CPU + {A4E32C0B-C878-4A6F-BF96-D99E8A025091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4E32C0B-C878-4A6F-BF96-D99E8A025091}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4E32C0B-C878-4A6F-BF96-D99E8A025091}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4E32C0B-C878-4A6F-BF96-D99E8A025091}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/build/Our.Umbraco.ValidationAttributes.targets b/src/build/Our.Umbraco.ValidationAttributes.targets deleted file mode 100644 index e3a4c2b..0000000 --- a/src/build/Our.Umbraco.ValidationAttributes.targets +++ /dev/null @@ -1,27 +0,0 @@ - - - - $(MSBuildThisFileDirectory)..\App_Plugins\Our.Umbraco.ValidationAttributes\**\*.* - - - - - - - - - - - - - - - - - - - - \ No newline at end of file