Hello,
I'm working on some code generation for an existing project and I want to start from a xsd. So I can use tools as Xsd2Code / xsd.exe to generate the code and also the use the xsd to validate the xml. That part works without any problems.
I also want to translate some of the restrictions to DataAnnotations (enrich Xsd2Code). For example xs:minInclusive / xs:maxInclusive I can translate to a RangeAttribute.
But what to do with custom validation attributes that we created? Can I add custom facets / restrictions? And how? Or is there another solution / best practice.
I would like to collect everything in a single (xsd) file so that one file contains the structure of the class (model) including the validation (attributes) that has to be added.
<xs:element name="CertainValue">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minInclusive value="1" />
<xs:maxInclusive value="100" />
<xs_custom:customRule attribute="value" />
</xs:restriction>
</xs:simpleType>
</xs:element>