-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import a value type in electric vehicles example to demonstrate the p…
…ublish feature
- Loading branch information
1 parent
9b99142
commit 2d58952
Showing
2 changed files
with
84 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
// This file belongs to example 2: Electric Vehicles | ||
// Learning goals: | ||
// - Understand how to publish elements to use them in other files | ||
|
||
// 1. The publish keyword can be used directly when defining an element. | ||
publish valuetype UsStateCode oftype text { | ||
constraints: [ | ||
UsStateCodeAllowlist, | ||
]; | ||
} | ||
|
||
// 2. The publish keyword can be used after definition (see below). | ||
// When using this delayed publish syntax, the published element can also be renamed for access from outside of the file. | ||
constraint UsStateCodeAllowlist on text: value in [ | ||
"AL", | ||
"AK", | ||
"AZ", | ||
"AR", | ||
"AS", | ||
"CA", | ||
"CO", | ||
"CT", | ||
"DE", | ||
"DC", | ||
"FL", | ||
"GA", | ||
"GU", | ||
"HI", | ||
"ID", | ||
"IL", | ||
"IN", | ||
"IA", | ||
"KS", | ||
"KY", | ||
"LA", | ||
"ME", | ||
"MD", | ||
"MA", | ||
"MI", | ||
"MN", | ||
"MS", | ||
"MO", | ||
"MT", | ||
"NE", | ||
"NV", | ||
"NH", | ||
"NJ", | ||
"NM", | ||
"NY", | ||
"NC", | ||
"ND", | ||
"MP", | ||
"OH", | ||
"OK", | ||
"OR", | ||
"PA", | ||
"PR", | ||
"RI", | ||
"SC", | ||
"SD", | ||
"TN", | ||
"TX", | ||
"TT", | ||
"UT", | ||
"VT", | ||
"VA", | ||
"VI", | ||
"WA", | ||
"WV", | ||
"WI", | ||
"WY", | ||
]; | ||
|
||
publish UsStateCodeAllowlist as UsStateCodeConstraint; |