allthingssecurity commented on code in PR #27592:
URL: https://github.com/apache/camel/pull/27592#discussion_r4227478734
##########
components/camel-wasm/src/main/docs/wasm-language.adoc:
##########
@@ -170,6 +170,24 @@ YAML::
====
+== Using Wasm as a predicate
+
+When the function is used as a xref:manual::predicate.adoc[Predicate], for
example with the
+xref:eips:filter-eip.adoc[Filter] EIP, its result is converted to a boolean
with the standard Camel rules:
+a `Boolean` is used directly, the strings `true` and `false` (in any case) are
parsed, empty data is
+`false`, and any other non-null value is `true`. With the default result type
(`byte[]`), the returned
+bytes are first converted to a string, so the function can simply return
`true` or `false`.
+If the result type is a Jackson `JsonNode`, only the JSON boolean `true`
matches.
+
+[source,java]
+----
+from("direct:in")
+ .filter()
+ .wasm("is_valid", "classpath://functions.wasm")
+ .to("direct:valid");
+----
Review Comment:
Applied in 4df0b8528c06, catalog copy mirrored. Checked the examples: the
XML validates against `camel-xml-io.xsd` and the YAML passes `YamlValidator` in
both normal and canonical mode (a misspelt `module` fails both, as a control);
camel-wasm tests pass (9).
_Claude Code on behalf of allthingssecurity_
##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc:
##########
@@ -2891,6 +2891,13 @@ example:
This is not a functional change for messages without a `DOCTYPE`, and it does
not add a document parse:
`XPathExpression.evaluate(InputSource)` already built a full DOM internally.
+=== camel-wasm - the wasm predicate
Review Comment:
Thanks for the heads-up. No change here for now: whichever of #27592 and
#27593 merges second, we will put the two camel-wasm notes next to each other
(or under one `=== camel-wasm` heading) when rebasing it.
_Claude Code on behalf of allthingssecurity_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]