Skip to content

Commit

Permalink
Merge pull request #28 from wongvincent/vwong/US123496-Add-Min-Max-to…
Browse files Browse the repository at this point in the history
…-SirenField

SirenField Min Max, change from int? to decimal?
  • Loading branch information
wongvincent authored Jan 12, 2021
2 parents 98e6ce4 + 3e753c7 commit 8f64146
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions D2L.Hypermedia.Siren/ISirenField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public interface ISirenField : ISirenSerializable, IEquatable<ISirenField>, ICom

string Title { get; }

int? Min { get; }
decimal? Min { get; }

int? Max { get; }
decimal? Max { get; }

}

Expand Down
2 changes: 1 addition & 1 deletion D2L.Hypermedia.Siren/JsonUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void WriteJsonObject( JsonWriter writer, string propertyName, obje
writer.WriteRawValue( JsonConvert.SerializeObject( value ) );
}

public static void WriteJsonNumber( JsonWriter writer, string propertyName, int? value ) {
public static void WriteJsonNumber( JsonWriter writer, string propertyName, decimal? value ) {
if( value == null ) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions D2L.Hypermedia.Siren/SirenField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public class SirenField : ISirenField {
private readonly string m_type;
private readonly string[] m_class;
private readonly string m_name;
private readonly int? m_min;
private readonly int? m_max;
private readonly decimal? m_min;
private readonly decimal? m_max;

public SirenField(
string name,
string[] @class = null,
string type = null,
object value = null,
string title = null,
int? min = null,
int? max = null
decimal? min = null,
decimal? max = null
) {
m_name = name;
m_class = @class ?? new string[0];
Expand Down Expand Up @@ -62,10 +62,10 @@ private string ValidateType( string type ) {
public string Title => m_title;

[JsonProperty( "min", NullValueHandling = NullValueHandling.Ignore )]
public int? Min => m_min;
public decimal? Min => m_min;

[JsonProperty( "max", NullValueHandling = NullValueHandling.Ignore )]
public int? Max => m_max;
public decimal? Max => m_max;

public bool ShouldSerializeClass() {
return Class.Length > 0;
Expand Down

0 comments on commit 8f64146

Please sign in to comment.