Class Age
- Namespace
- Trellis.Primitives
- Assembly
- Trellis.Primitives.dll
Age value object with validation for ages 0-150.
[JsonConverter(typeof(ParsableJsonConverter<Age>))]
public class Age : ScalarValueObject<Age, int>, IComparable<ValueObject>, IEquatable<ValueObject>, IConvertible, IScalarValue<Age, int>, IParsable<Age>
- Inheritance
-
Age
- Implements
- Inherited Members
- Extension Methods
Remarks
Validation Rules (Opinionated):
- Must be non-negative (>= 0)
- Must be realistic (<= 150)
If these rules don't fit your domain, create your own Age value object using the ScalarValueObject<TSelf, T> base class from the DomainDrivenDesign package.
Methods
Parse(string?, IFormatProvider?)
Parses an age.
public static Age Parse(string? s, IFormatProvider? provider)
Parameters
sstringproviderIFormatProvider
Returns
TryCreate(int, string?)
Attempts to create an age.
public static Result<Age> TryCreate(int value, string? fieldName = null)
Parameters
Returns
TryParse(string?, IFormatProvider?, out Age)
Tries to parse an age.
public static bool TryParse(string? s, IFormatProvider? provider, out Age result)
Parameters
sstringproviderIFormatProviderresultAge