diff --git a/engine/baml-lib/baml/tests/validation_files/functions_v2/check_in_parameter.baml b/engine/baml-lib/baml/tests/validation_files/functions_v2/check_in_parameter.baml new file mode 100644 index 000000000..bece0ae27 --- /dev/null +++ b/engine/baml-lib/baml/tests/validation_files/functions_v2/check_in_parameter.baml @@ -0,0 +1,24 @@ +client MyClient { + provider baml-openai-chat +} + +class Foo { + bar Bar? + baz int +} + +class Bar { + name string @check({{ this|length > 0 }}, nonempty_name) +} + +function Go(a: Foo) -> int { + client MyClient + prompt #"Hi"# +} + +// error: Error validating: Types with checks are not allowed as function parameters. +// --> functions_v2/check_in_parameter.baml:14 +// | +// 13 | +// 14 | function Go(a: Foo) -> int { +// | diff --git a/engine/language_client_typescript/checked.d.ts b/engine/language_client_typescript/checked.d.ts new file mode 100644 index 000000000..b4a4ce27c --- /dev/null +++ b/engine/language_client_typescript/checked.d.ts @@ -0,0 +1,14 @@ +export interface Checked { + value: T; + checks: K; +} +interface Check { + name: string; + expr: string; + result: "succeeded" | "failed"; +} +interface BaseChecks { + [key: string]: Check; +} +export {}; +//# sourceMappingURL=checked.d.ts.map \ No newline at end of file diff --git a/engine/language_client_typescript/checked.d.ts.map b/engine/language_client_typescript/checked.d.ts.map new file mode 100644 index 000000000..65e7e30a7 --- /dev/null +++ b/engine/language_client_typescript/checked.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"checked.d.ts","sourceRoot":"","sources":["typescript_src/checked.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO,CAAC,CAAC,EAAC,CAAC,SAAS,UAAU;IAC3C,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,EAAE,CAAC,CAAC;CACb;AAED,UAAU,KAAK;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAA;CACjC;AAED,UAAU,UAAU;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;CACvB"} \ No newline at end of file diff --git a/engine/language_client_typescript/checked.js b/engine/language_client_typescript/checked.js new file mode 100644 index 000000000..00a461ab4 --- /dev/null +++ b/engine/language_client_typescript/checked.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function all_succeeded(checks) { + return Object.values(checks).every(value => value.result == "succeeded"); +}