Validation Rules
Built-in business rules for SFRS filings
SFRS includes built-in business rules that catch errors at filing time.
| Rule | Description | Severity |
|---|
| BAL001 | Total Assets = Total Liabilities + Total Stockholders' Equity | Error |
| BAL002 | Total Current Assets + Total Noncurrent Assets = Total Assets | Error |
| BAL003 | Total Current Liabilities + Total Noncurrent Liabilities = Total Liabilities | Error |
totalAssets == totalLiabilities + totalStockholdersEquity
This is the fundamental accounting equation. Every filing must balance.
| Rule | Description | Severity |
|---|
| IS001 | Gross Profit = Revenue - Cost of Revenue | Error |
| IS002 | Operating Income = Gross Profit - Operating Expenses | Error |
| IS003 | Net Income = Income Before Tax - Income Tax Expense | Warning |
grossProfit == revenue - costOfRevenue
| Rule | Description | Severity |
|---|
| CF001 | Net Change in Cash = Operating + Investing + Financing | Error |
| CF002 | Free Cash Flow = Operating Cash Flow - CapEx | Warning |
netChangeInCash == netCashFromOperating + netCashFromInvesting + netCashFromFinancing
| Rule | Description | Severity |
|---|
| EPS001 | Basic EPS equals Net Income / Weighted Average Shares | Warning |
| EPS002 | Diluted EPS must be less than or equal to Basic EPS | Warning |
| EPS003 | Diluted Shares must be greater than or equal to Basic Shares | Warning |
earningsPerShareBasic ~= netIncome / sharesOutstandingBasic
Allows for rounding tolerance based on decimals precision.
| Rule | Description | Severity |
|---|
| DIM001 | Segment revenues must sum to total revenue | Error |
| DIM002 | Geographic revenues must sum to total revenue | Error |
| Rule | Description | Severity |
|---|
| EXT001 | All extensions must have valid extensionApprovalId | Error |
| EXT002 | extensionApprovalId must match pattern EXT-[A-Z]{2,4}-YYYY-NNNNNN | Error |
import { validateFiling } from '@sureshake/sfrs-validator';
const result = validateFiling(filing);
console.log('Valid:', result.valid);
console.log('Errors:', result.errors);
console.log('Warnings:', result.warnings);
// result.errors = [
// {
// code: 'BAL-001',
// path: 'balanceSheet',
// message: 'Total assets (6000000000) does not equal liabilities + equity (5900000000)',
// severity: 'error'
// }
// ]
| Level | Description | Filing Blocked? |
|---|
| Error | Critical issue, filing is invalid | Yes |
| Warning | Potential issue, should review | No |
| Info | Informational notice | No |
The validator supports custom business rules:
import { SFRSFilingValidator } from '@sureshake/sfrs-validator';
const validator = new SFRSFilingValidator();
// Add custom rule
validator.addRule({
id: 'CUSTOM-001',
name: 'Revenue Growth Check',
description: 'Revenue should not decrease by more than 50%',
severity: 'warning',
validate: (filing, priorFiling) => {
if (!priorFiling) return { valid: true };
const currentRevenue = filing.facts.revenue?.value || 0;
const priorRevenue = priorFiling.facts.revenue?.value || 0;
const decline = (priorRevenue - currentRevenue) / priorRevenue;
return {
valid: decline < 0.5,
message: `Revenue declined by ${(decline * 100).toFixed(1)}%`
};
}
});
const result = validator.validate(filing);