Skip to content

Commit

Permalink
Allow negative numbers in decimal type (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdouceur authored Oct 11, 2024
1 parent 0e42fbf commit 772de8e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dotnet/src/DTDLParser/generated/DTDecimalInfo.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class DTDecimalInfo : DTNumericSchemaInfo, ITypeChecker, IConstrainer, IE

private static readonly HashSet<string> VersionlessTypes = new HashSet<string>();

private static readonly Regex ElementValueInstanceRegexPatternV4 = new Regex(@"^(?:[1-9][0-9]*|0)(?:\.[0-9]*)?$", RegexOptions.Compiled);
private static readonly Regex ElementValueInstanceRegexPatternV4 = new Regex(@"^(?:\+|-)?(?:[1-9][0-9]*|0)(?:\.[0-9]*)?$", RegexOptions.Compiled);

private bool checkedForDescendantSchemaArray = false;

Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/DTDLParser/generated/ModelElements.g.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
"Decimal"
],
"description": {
"en-US": "a string of decimal digits with an optional decimal point and fractional component"
"en-US": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"displayName": "decimal"
},
Expand Down
14 changes: 7 additions & 7 deletions dtdl/dtdl_digest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@
"Decimal"
],
"description": {
"en-US": "a string of decimal digits with an optional decimal point and fractional component"
"en-US": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"displayName": "decimal"
},
Expand Down Expand Up @@ -19674,7 +19674,7 @@
"4": [
{
"description": {
"en-us": "a string of decimal digits with an optional decimal point and fractional component"
"en-us": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"id": "dtmi:dtdl:instance:Schema:decimal;4",
"name": "decimal"
Expand All @@ -19699,7 +19699,7 @@
"element": {
"datatype": "decimal",
"jsonType": "string",
"pattern": "^(?:[1-9][0-9]*|0)(?:\\.[0-9]*)?$"
"pattern": "^(?:\\+|-)?(?:[1-9][0-9]*|0)(?:\\.[0-9]*)?$"
}
},
"conformanceText": "the XSD definition of 'decimal'",
Expand Down Expand Up @@ -21054,7 +21054,7 @@
},
{
"description": {
"en-us": "a string of decimal digits with an optional decimal point and fractional component"
"en-us": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"id": "dtmi:dtdl:instance:Schema:decimal;4",
"name": "decimal"
Expand Down Expand Up @@ -26564,7 +26564,7 @@
},
{
"description": {
"en-us": "a string of decimal digits with an optional decimal point and fractional component"
"en-us": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"id": "dtmi:dtdl:instance:Schema:decimal;4",
"name": "decimal"
Expand Down Expand Up @@ -27706,7 +27706,7 @@
},
{
"description": {
"en-us": "a string of decimal digits with an optional decimal point and fractional component"
"en-us": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"id": "dtmi:dtdl:instance:Schema:decimal;4",
"name": "decimal"
Expand Down Expand Up @@ -29509,7 +29509,7 @@
},
{
"description": {
"en-us": "a string of decimal digits with an optional decimal point and fractional component"
"en-us": "a string of decimal digits with an optional decimal point and fractional component, optionally preceded by a sign"
},
"id": "dtmi:dtdl:instance:Schema:decimal;4",
"name": "decimal"
Expand Down
40 changes: 40 additions & 0 deletions test-cases/generated/DecimalInstancesV4.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
"conforms": true,
"submit": "\"0\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"+0\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"-0\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": false,
Expand All @@ -33,6 +43,16 @@
"conforms": true,
"submit": "\"1\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"+1\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"-1\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
Expand All @@ -43,6 +63,16 @@
"conforms": true,
"submit": "\"123\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"+123\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"-123\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": false,
Expand Down Expand Up @@ -108,6 +138,16 @@
"conforms": true,
"submit": "\"1.5\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"+1.5\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
"submit": "\"-1.5\""
},
{
"subject": "dtmi:dtdl:instance:Schema:decimal;4",
"conforms": true,
Expand Down

0 comments on commit 772de8e

Please sign in to comment.