Skip to content

Commit

Permalink
Merge pull request #250 from Peefy/fix-error-regex-in-index-signature…
Browse files Browse the repository at this point in the history
…-example

fix: error regex expressions in the index signature examples
  • Loading branch information
jakezhu9 authored Jan 15, 2024
2 parents 6ce7048 + 6229f7b commit c687bea
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/reference/lang/spec/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/lang/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,20 @@ data = Data {
}
```

```python
import regex

schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
"foo.bar" = "value2" # check error
}
```

##### 继承

类似于其他面向对象语言,KCL 提供了基础且有限的面向对象支持,例如 **属性复用****私有和公有变量****单继承**。KCL 不支持多继承。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,20 @@ data = Data {
}
```

```python
import regex

schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
"foo.bar" = "value2" # check error
}
```

##### 继承

类似于其他面向对象语言,KCL 提供了基础且有限的面向对象支持,例如 **属性复用****私有和公有变量****单继承**。KCL 不支持多继承。
Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-0.7.0/reference/lang/spec/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-0.7.0/reference/lang/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ import regex
schema DataMap:
[attr: str]: str
check:
regex.match(attr, r'^[-._a-zA-Z0-9]+$')
regex.match(attr, r'^[-_a-zA-Z0-9]+$')

data = DataMap {
key1 = "value1"
Expand Down

0 comments on commit c687bea

Please sign in to comment.