File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -129,3 +129,32 @@ class FileNotFound(FileError):
129
129
class FileNotReadable (FileError ):
130
130
...
131
131
~~~~~~~~
132
+
133
+ ### ` @numeric-constraints ` {#numeric-constraints}
134
+
135
+ ` @numeric-constraints ` annotation constrain the range of the input value.
136
+ Currently, available annotation arguments are below:
137
+
138
+ ` min ` : Minimum input value; inclusive
139
+
140
+ ` max ` : Maximum input value; inclusive
141
+
142
+ For example, the following first Nirum code is compiled to the second Python
143
+ code:
144
+
145
+ ~~~~~~~~ nirum
146
+ @numeric-constraints(min=1, max=12)
147
+ unboxed month (int32);
148
+ ~~~~~~~~
149
+
150
+ ~~~~~~~~ python
151
+ class Month (object ):
152
+ ...
153
+ def __init__ (self , value : ' __builtin__.int' ) -> None :
154
+ ...
155
+ if not (value <= (12 )):
156
+ raise ValueError (" value is greater than 12" )
157
+ if not (value >= (1 )):
158
+ raise ValueError (" value is less than 1" )
159
+ ...
160
+ ~~~~~~~~
You can’t perform that action at this time.
0 commit comments