Skip to content

Commit

Permalink
US97770 Validate field type
Browse files Browse the repository at this point in the history
Siren imposes limits on what a Siren field's `type` can be, but this was not being enforced by this library. As a first step, add SirenFieldType, which includes all the valid field types. This is a non-breaking change, which will be followed up by updating usages of this library to use SirenFieldType instead of a string, followed by a breaking change here to update the constructor to only allow for SirenFieldType.
  • Loading branch information
ryantmer committed Jul 4, 2018
1 parent a834954 commit a752e48
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion D2L.Hypermedia.Siren.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Desire2Learn")]
[assembly: AssemblyProduct("D2L.Hypermedia.Siren.Tests")]
[assembly: AssemblyCopyright("Copyright © Desire2Learn 2016")]
[assembly: AssemblyCopyright("Copyright © Desire2Learn 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
1 change: 1 addition & 0 deletions D2L.Hypermedia.Siren/D2L.Hypermedia.Siren.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<ItemGroup>
<Compile Include="ISirenSerializable.cs" />
<Compile Include="JsonUtilities.cs" />
<Compile Include="SirenFieldType.cs" />
<Compile Include="SirenMatchers.cs" />
<Compile Include="SirenActionExtensions.cs" />
<Compile Include="SirenEntityExtensions.cs" />
Expand Down
2 changes: 1 addition & 1 deletion D2L.Hypermedia.Siren/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Desire2Learn")]
[assembly: AssemblyProduct("D2L.Hypermedia.Siren")]
[assembly: AssemblyCopyright("Copyright © Desire2Learn 2017")]
[assembly: AssemblyCopyright("Copyright © Desire2Learn 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
27 changes: 27 additions & 0 deletions D2L.Hypermedia.Siren/SirenFieldType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace D2L.Hypermedia.Siren {

public class SirenFieldType {

public static string Hidden => "hidden";
public static string Text => "text";
public static string Search => "search";
public static string Tel => "tel";
public static string Url => "url";
public static string Email => "email";
public static string Password => "password";
public static string Datetime => "datetime";
public static string Date => "date";
public static string Month => "month";
public static string Week => "week";
public static string Time => "time";
public static string DatetimeLocal => "datetime-local";
public static string Number => "number";
public static string Range => "range";
public static string Color => "color";
public static string Checkbox => "checkbox";
public static string Radio => "radio";
public static string File => "file";

}

}

0 comments on commit a752e48

Please sign in to comment.