Skip to content

Commit d1a82ee

Browse files
author
Ruben van Leeuwen
committed
1694: Renames ASN field to the more generic Number
1 parent ae79b9f commit d1a82ee

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

backend/main.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,14 @@ def __iter__(self) -> Iterator[BaseMetadata]:
6464
yield Field(json_schema_extra=self.props)
6565

6666

67-
def valid_asn_rfc7300(val: int) -> bool:
68-
if val == 65535:
69-
raise ValueError("RFC 7300 doesn't allow 65535 as ASN value")
67+
def example_backend_validation(val: int) -> bool:
68+
if val == 9:
69+
raise ValueError("Value cannot be 9")
7070
return True
7171

7272

73-
Asn = Annotated[
74-
int,
75-
Ge(1),
76-
Le(10),
77-
MultipleOf(multiple_of=3),
78-
Predicate(valid_asn_rfc7300),
79-
doc("Autonomous System Number."),
73+
NumberExample = Annotated[
74+
int, Ge(1), Le(10), MultipleOf(multiple_of=3), Predicate(example_backend_validation)
8075
]
8176

8277

@@ -86,8 +81,8 @@ def form_generator(state: State):
8681
class TestForm(FormPage):
8782
model_config = ConfigDict(title="Form Title")
8883

89-
asn: Asn
90-
text: Annotated[str, Field(min_length=3, max_length=10)] = "Default text"
84+
number: NumberExample
85+
text: Annotated[str, Field(min_length=3, max_length=12)] = "Default text"
9186
textArea: LongText
9287
divider: Divider
9388
label: Label = "Label"

0 commit comments

Comments
 (0)