Skip to content

Commit

Permalink
Added support for length facet
Browse files Browse the repository at this point in the history
  • Loading branch information
bcallaghan-et committed Apr 23, 2020
1 parent f0f0502 commit 4a85b5d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,20 @@ private IEnumerable<RestrictionModel> GetRestrictions(IEnumerable<XmlSchemaFacet

foreach (var facet in facets)
{
if (facet is XmlSchemaLengthFacet)
{
var value = int.Parse(facet.Value);
if (_configuration.DataAnnotationMode == DataAnnotationMode.All)
{
yield return new MinLengthRestrictionModel(_configuration) { Value = value };
yield return new MaxLengthRestrictionModel(_configuration) { Value = value };
}
else
{
yield return new MinMaxLengthRestrictionModel(_configuration) { Min = value, Max = value };
}
}

if (facet is XmlSchemaTotalDigitsFacet)
{
yield return new TotalDigitsRestrictionModel(_configuration) { Value = int.Parse(facet.Value) };
Expand Down

0 comments on commit 4a85b5d

Please sign in to comment.