Custom validation
Apply custom rules to files with AI.
Custom validation lets you write your own validation logic in code and, where needed, use an AI model to interpret and apply rules that go beyond what a template can express. Use it when standard column-and-type checks in Validate files aren't enough and you need business-specific or free-text validation logic.
Availability: Requires the
WorkflowsCustomFileValidationfeature. Contact your OneSchema support representative if you do not see this transform.
What it does
- Input: files or lists (one or more, of any type).
- Output: the same files or lists, with custom validation logic applied. Rows or files that violate your rules are flagged for review or downstream handling.
- The transform runs a code snippet you provide against each input. The snippet can call an AI model to evaluate conditions that are hard to express as strict rules, such as interpreting free-text fields, checking semantic consistency across columns, or applying business logic that depends on multiple fields at once.
When to use it
- You need validation logic that isn't supported by standard template-based validation, such as conditional rules ("if Column A is blank, Column B must be filled in").
- You want to validate free-text fields for intent or content, like checking that a comments field doesn't contain disallowed language.
- You're enforcing business rules that combine multiple columns or reference external context that a simple type check can't capture.
- You need the same custom logic applied consistently across many files or list outputs in a feed.
How to configure it
In the MFF builder, add a Custom validation node after the node that produces the files or lists you want to check.
Settings
| Setting | Description | Default |
|---|---|---|
| Code | A code snippet that defines your custom validation logic. Edit it in the settings panel to add rules, call an AI model for semantic checks, and decide how failures are flagged. | Default code snippet |
Code tips
- Start from the default code snippet and modify the conditions rather than writing from scratch.
- Keep rules narrow and specific; broad AI prompts inside the code can produce inconsistent results.
- Return clear, consistent flags or error messages so downstream nodes can act on them predictably.
Example
Input
A CSV list of support tickets with columns Ticket ID, Priority, Description.
Output
The same list, with tickets flagged where Priority is set to "Low" but the Description text indicates an urgent issue, based on a custom rule in the code snippet that uses AI to assess the description's tone.
Troubleshooting
Validation results are inconsistent between runs
- Narrow the scope of any AI-driven checks in your code snippet; broad or ambiguous prompts inside the logic can produce varying results.
- Add explicit conditions in code where possible, reserving AI calls only for genuinely ambiguous fields.
Code snippet throws an error
- Check the snippet for syntax errors or unhandled cases, such as missing columns in some input files.
- Test the snippet against a small sample file before running it across a full feed.
Some rows should be flagged but aren't
- Review your code's conditions for edge cases, such as empty values or unexpected data types.
- Consider combining this transform with Validate files to catch straightforward schema issues first, reserving custom logic for business-specific checks.
See also
Updated 1 day ago