Skip to content

Commit 6427346

Browse files
Better message for component prop label validation
1 parent 8f79f6f commit 6427346

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/yew-macro/src/props/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn validate(props: Props) -> Result<Props, syn::Error> {
194194
PropLabel::Static(dashed_name) if dashed_name.extended.is_empty() => Ok(()),
195195
_ => Err(syn::Error::new_spanned(
196196
&prop.label,
197-
"expected a valid Rust identifier",
197+
"components expect valid Rust identifiers for their property names",
198198
)),
199199
})?;
200200

packages/yew-macro/tests/html_macro/component-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ error: the property value must be either a literal or enclosed in braces. Consid
259259
86 | html! { <Child ref=() /> };
260260
| ^^
261261

262-
error: expected a valid Rust identifier
262+
error: components expect valid Rust identifiers for their property names
263263
--> tests/html_macro/component-fail.rs:87:20
264264
|
265265
87 | html! { <Child invalid-prop-name=0 /> };

packages/yew-macro/tests/html_macro/dyn-prop-fail.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
error: expected a valid Rust identifier
1+
error: components expect valid Rust identifiers for their property names
22
--> tests/html_macro/dyn-prop-fail.rs:66:32
33
|
44
66 | _ = ::yew::html! { <Simple "test"="" /> };
55
| ^^^^^^
66

7-
error: expected a valid Rust identifier
7+
error: components expect valid Rust identifiers for their property names
88
--> tests/html_macro/dyn-prop-fail.rs:67:32
99
|
1010
67 | _ = ::yew::html! { <Simple "test"={ "" } /> };
1111
| ^^^^^^
1212

13-
error: expected a valid Rust identifier
13+
error: components expect valid Rust identifiers for their property names
1414
--> tests/html_macro/dyn-prop-fail.rs:68:34
1515
|
1616
68 | _ = ::yew::html! { <Simple { "test" }={ "" } /> };
1717
| ^^^^^^
1818

19-
error: expected a valid Rust identifier
19+
error: components expect valid Rust identifiers for their property names
2020
--> tests/html_macro/dyn-prop-fail.rs:69:34
2121
|
2222
69 | _ = ::yew::html! { <Simple { dyn_prop() }={ "" } /> };

0 commit comments

Comments
 (0)