Turn complex logicinto clear decisions
Bantai evaluates real-world inputs into deterministic, explainable allow/deny decisions with full TypeScript safety.
ENGINEERED FOR
DETERMINISM.
TypeScript-First & Zod-Powered
Built with TypeScript and Zod for end-to-end type safety. Define your context schemas and get full autocompletion across your logic.
Policy-Based Evaluation
Bantai isn't just validation. It's a deterministic engine that separates your business rules from your execution flow for clean audits.
Composable Rules & Strategies
Compose modular rules into powerful policies. Use 'preemptive' strategy to fail fast or 'exhaustive' to collect all violations.
Environment Agnostic
Works anywhere JavaScript runs. Deploy in Next.js Middleware, Cloudflare Workers, Node.js servers, or even the browser.
LOGIC IN FIVE
PHASES.
Define Context
Use defineContext(z.object({...})) to establish your schema requirements.
Craft Rules
Write individual validation rules that return typed allow() or deny() responses.
Compose Policies
Group multiple rules into a single policy with custom evaluation strategies.
Execute Eval
Trigger evaluatePolicy() with real-time data to get an instant decision.
Handle Results
Utilize decision and violatedRules arrays to power your application's logic.
POLICY-FIRST
DESIGN.
Bantai treats policies as the single source of truth. By decoupling definitions from implementation, you ensure auditable behavior across all environments.
- Zero hardcoded limits
- Auditable request logic
- Environment parity
- Predictable scaling
LIBRARY MODE
Fully flexible, code-driven usage. Best for specific request guards inside your existing application logic.
RUNTIME MODE (SOON)
Config-driven, centralized control. Best for platform teams managing multiple services with global policies.
CLEAN
IMPLEMENTATION.
Bantai sits in the middle of your application and its decisions. Use our declarative API to craft explainable, type-safe logic in minutes.
import { z } from 'zod';
import { defineContext } from '@bantai-dev/core';
// Define your input schema
export const userContext = defineContext(
z.object({
age: z.number().min(0),
role: z.enum(['admin', 'editor', 'guest']),
isKycVerified: z.boolean()
})
);VERSATILE BY DESIGN.
Authorization & Access Control
Complex permission trees and multi-tenant logic.
Fintech Risk & Compliance
KYC verification and transaction limit evaluation.
AI / LLM Guardrails
Evaluate prompts for risk scores and confidence thresholds.
Business Rule Engines
Move dynamic logic out of code and into policies.
Feature Flags & Entitlements
Determine user features based on subscription context.
OSS Trust Signals
Evaluate contributor reputation and code quality metrics.
BUILT IN
THE OPEN.
Bantai is 100% open-source and MIT licensed. We believe critical decision logic should be transparent and auditable by everyone.