Skip to content

Commit

Permalink
Merge pull request #182 from Etogy/master
Browse files Browse the repository at this point in the history
Add support for length facet
  • Loading branch information
mganss authored Apr 24, 2020
2 parents f0f0502 + 4a85b5d commit 54379ab
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 54379ab

Please sign in to comment.