Home / Blog / Documentation / Code Generator / Settings / Annotation Attribute
Restrictions are used to define acceptable values for XML or JSon elements or attributes. Restrictions on XML elements are called facets, JSon restrictions are called semantics.
In this section we will go over the various settings that interact with the restrictions. Most of these settings let you transport specifications already set in you schemas into you c# classes
Firstly, you can find the settings under the "Output property settings", from there you can open the "DataAnnotationsAttribute" settings, like so :
With this setting you can carry over the default value set in you schema, this default value will be applied to the appropriate attributes in the c# classes.
Here's what the restriction looks like in an Xsd and it's generated version :
Xsd :
Generated version :
With this setting you can transport your schema's fraction digits restriction into your generated code, this restriction defines the maximum number of fractional digits (i.e., digits that are after the decimal point). Must be equal to or greater than zero
Here's what this restriction looks like in an xsd and its generated version :
Xsd :
Generated version :
With this setting you can carry over your total digit limit restriction from your schema.
This restriction specifies the exact number of digits allowed. It must be greater than zero
Here's an example :
Xsd :
Generated version :
With these settings you can carry over from your schema your a maximum and/or minimum length restrictions on your attributes.
Here's an example of these settings in xsd and their generated versions :
Xsd :
Generated version :
With this setting you can carry over your set range for certain attributes into your generated class.
Here's an example of a range restriction on an xsd attribute and it's generated version :
Xsd :
Generated code :
With this setting you can carry over your regular expressions from your schema to your generated code.
This restriction allows the definition of regular expression patterns over the lexical space. The syntax used for these patterns has been borrowed from Perl regular expressions, and has been enhanced to support the Unicode character blocks.
With this setting you can set wether or not the required attribute is carried over from your schema, this attribute defines some attributes as required, meaning they need to have a value.
For example , in an Xsd the specification will turn in to this in your c# class :
With these settings you can carry over from your schema your a maximum and/or minimum length restrictions on your string attributes.
Here's an example of these settings in xsd and their generated versions :
Xsd :
Generated version :
With this setting you can will generate a validator function in the setter
Terms & privacy |
Contact CodeNGine Technologies SIRET: 85257252800010, VAT : FR 62852572528 |
About the company CodeNGine Technologies is software company based in the South of France that provides an advanced productivity code generation tool to developers using XML and JSON |
Copyright © 2021 CodeNGine Technologies