dsers.rules.validate
Validate and normalize product rules for DSers dropshipping. Check pricing, content, and image rules against store capabilities before import to identify issues and preview applied rules.
Instructions
Check and normalize a rules object against the provider's capabilities before importing. Use this to verify pricing, content, and image rules are valid and see exactly which ones will be applied. Returns: effective_rules_snapshot (what will actually be applied), warnings (adjustments made), errors (blocking issues that must be fixed before calling dsers.product.import).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rules | Yes | Rules as a JSON string. Top-level keys: pricing, content, images. Example: {"pricing": {"mode": "multiplier", "multiplier": 2.5}, "content": {"title_prefix": "[US] "}, "images": {"keep_first_n": 5}} | |
| target_store | No | Store ID or display name from dsers.store.discover. Some rule capabilities vary by store. |
Implementation Reference
- src/tools.ts:98-108 (handler)The handler function for 'dsers.rules.validate' which parses the input JSON string and calls the service method `svc().validateRules`.
async ({ rules, target_store }) => { try { const parsed = safeJsonParse( rules, "rules", 'Expected a JSON object with optional keys: pricing, content, images. ' + 'Example: {"pricing": {"mode": "multiplier", "multiplier": 2.0}}', ); if (parsed.error) return fail(new Error(parsed.error)); return ok(await svc().validateRules({ rules: parsed.value, target_store: target_store || null })); } catch (err) { return fail(err); } }, - src/tools.ts:70-109 (registration)Tool registration for 'dsers.rules.validate' in src/tools.ts.
server.registerTool( "dsers.rules.validate", { title: "Dropshipping Pricing & Content Rule Validator", description: "Check and normalize a rules object against the provider's capabilities before importing. " + "Use this to verify pricing, content, and image rules are valid and see exactly which ones will be applied. " + "Returns: effective_rules_snapshot (what will actually be applied), warnings (adjustments made), errors (blocking issues that must be fixed before calling dsers.product.import).", inputSchema: { rules: z.string().describe( "Rules as a JSON string. Top-level keys: pricing, content, images. " + 'Example: {"pricing": {"mode": "multiplier", "multiplier": 2.5}, ' + '"content": {"title_prefix": "[US] "}, "images": {"keep_first_n": 5}}', ), target_store: z .string() .optional() .describe( "Store ID or display name from dsers.store.discover. Some rule capabilities vary by store.", ), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async ({ rules, target_store }) => { try { const parsed = safeJsonParse( rules, "rules", 'Expected a JSON object with optional keys: pricing, content, images. ' + 'Example: {"pricing": {"mode": "multiplier", "multiplier": 2.0}}', ); if (parsed.error) return fail(new Error(parsed.error)); return ok(await svc().validateRules({ rules: parsed.value, target_store: target_store || null })); } catch (err) { return fail(err); } }, );