Skip to content

Commit

Permalink
Adjust docs & changelog for PR #271
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Aug 17, 2018
1 parent 5d1fa86 commit 74708ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ To be released.

- The `uri` type has completly gone; use `url` instead.
[[#126], [#281] by Jonghun Park]
- Added constraints for numeric unboxed types. [[#206], [#271]]
- Added [`@numeric-constraints`](docs/annotation.md#numeric-constraints)
annotation to constraint the range of unboxed types' values.
[[#206], [#271] by Seunghun Lee]

### Docs target

Expand Down
18 changes: 9 additions & 9 deletions docs/annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ class FileNotReadable(FileError):

### `@numeric-constraints` {#numeric-constraints}

`@numeric-constraints` annotation constrain the range of the input value.
`@numeric-constraints` annotation constrains the range of unboxed types' values.
Currently, available annotation arguments are below:

`min`: Minimum input value; inclusive
`min`
: Minimum input value; inclusive.

`max`: Maximum input value; inclusive
`max`
: Maximum input value; inclusive.

For example, the following first Nirum code is compiled to the second Python
code:
Expand All @@ -148,13 +150,11 @@ unboxed month (int32);
~~~~~~~~

~~~~~~~~ python
class Month(object):
...
def __init__(self, value: '__builtin__.int') -> None:
...
if not (value <= (12)):
class Month:
def __init__(self, value: int) -> None:
if not value <= 12:
raise ValueError("value is greater than 12")
if not (value >= (1)):
if not value >= 1:
raise ValueError("value is less than 1")
...
~~~~~~~~

0 comments on commit 74708ea

Please sign in to comment.