From c56cf4e24f6134547fb9c5b58eb20840f5083e9e Mon Sep 17 00:00:00 2001 From: Andrii Mokhovyk Date: Sun, 18 Jan 2026 16:36:49 +0200 Subject: feat(rules): add "Title Contains" condition to Rule Engine (#1670) (#2354) * feat(rules): add "Title Contains" condition to Rule Engine (#1670) * feat(rules): hide title conditions for bookmark created trigger * fix typecheck --- packages/shared/types/rules.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'packages/shared') diff --git a/packages/shared/types/rules.ts b/packages/shared/types/rules.ts index 0daec524..fd99c266 100644 --- a/packages/shared/types/rules.ts +++ b/packages/shared/types/rules.ts @@ -59,6 +59,16 @@ const zUrlDoesNotContainCondition = z.object({ str: z.string(), }); +const zTitleContainsCondition = z.object({ + type: z.literal("titleContains"), + str: z.string(), +}); + +const zTitleDoesNotContainCondition = z.object({ + type: z.literal("titleDoesNotContain"), + str: z.string(), +}); + const zImportedFromFeedCondition = z.object({ type: z.literal("importedFromFeed"), feedId: z.string(), @@ -86,6 +96,8 @@ const nonRecursiveCondition = z.discriminatedUnion("type", [ zAlwaysTrueCondition, zUrlContainsCondition, zUrlDoesNotContainCondition, + zTitleContainsCondition, + zTitleDoesNotContainCondition, zImportedFromFeedCondition, zBookmarkTypeIsCondition, zHasTagCondition, @@ -105,6 +117,8 @@ export const zRuleEngineConditionSchema: z.ZodType = zAlwaysTrueCondition, zUrlContainsCondition, zUrlDoesNotContainCondition, + zTitleContainsCondition, + zTitleDoesNotContainCondition, zImportedFromFeedCondition, zBookmarkTypeIsCondition, zHasTagCondition, @@ -244,6 +258,17 @@ const ruleValidaitorFn = ( return false; } return true; + case "titleContains": + case "titleDoesNotContain": + if (condition.str.length == 0) { + ctx.addIssue({ + code: "custom", + message: "You must specify a title for this condition type", + path: ["condition", "str"], + }); + return false; + } + return true; case "hasTag": if (condition.tagId.length == 0) { ctx.addIssue({ -- cgit v1.2.3-70-g09d2