Schema validation library for the Luca Ledger application. Provides type-safe validation for financial transactions, entities, and related data structures. Supports TypeScript.
npm install @luca-financial/luca-schemaimport { lucaValidator, enums, schemas } from '@luca-financial/luca-schema';
// Validate a transaction
const validateTransaction = lucaValidator.getSchema('transaction');
const transactionData = {
id: '123e4567-e89b-12d3-a456-426614174000',
payorId: '123e4567-e89b-12d3-a456-426614174001',
payeeId: '123e4567-e89b-12d3-a456-426614174002',
categoryId: '123e4567-e89b-12d3-a456-426614174003',
amount: 100.5,
date: '2024-01-01',
description: 'Test transaction',
transactionState: enums.TransactionStateEnum.COMPLETED,
createdAt: '2024-01-01T00:00:00Z',
updatedAt: null
};
const isValid = validateTransaction(transactionData);
if (!isValid) {
console.error('Validation errors:', validateTransaction.errors);
}
// Alternative: Use schemas directly with the validate method
const isValidDirect = lucaValidator.validate(
schemas.transaction,
transactionData
);Validates financial transactions with properties like amount, date, and state.
const transaction = {
id: string;
payorId: string;
payeeId: string;
categoryId: string | null;
amount: number;
date: string;
description: string;
transactionState: TransactionState;
createdAt: string;
updatedAt: string | null;
};Validates recurring transaction templates with frequency and interval settings.
const recurringTransaction = {
id: string;
payorId: string;
payeeId: string;
categoryId: string | null;
amount: number;
description: string;
frequency: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
interval: number;
occurrences: number | null;
startOn: string;
endOn: string | null;
recurringTransactionState: 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'CANCELLED';
createdAt: string;
updatedAt: string | null;
};Validates financial entities like accounts, retailers, or individuals.
const entity = {
id: string;
name: string;
description: string | null;
entityType: 'ACCOUNT' | 'RETAILER' | 'SERVICE' | 'INDIVIDUAL' | 'UTILITY' | 'GOVERNMENT';
entityStatus: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED' | 'DELETED' | 'CLOSED';
createdAt: string;
updatedAt: string | null;
};Validates transaction categories with optional parent relationships.
const category = {
id: string;
name: string;
description: string | null;
parentId: string | null;
defaultCategoryId: string | null;
categoryType: 'DEFAULT' | 'MODIFIED' | 'CUSTOM';
createdAt: string;
updatedAt: string | null;
};Validates events that track changes to recurring transactions.
const recurringTransactionEvent = {
id: string;
transactionId: string;
recurringTransactionId: string;
expectedDate: string;
eventState: 'MODIFIED' | 'DELETED';
createdAt: string;
updatedAt: string | null;
};yarn build # Build the library
yarn test # Run tests
yarn lint # Check code style
yarn type-check # Check TypeScript types- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.