@thearchitech.xyz/validator
v0.1.1
Published
Genome validation library for The Architech ecosystem
Maintainers
Readme
@thearchitech.xyz/validator
Genome validation library for The Architech ecosystem.
✅ Test Results
All validation rules tested and working:
- ✅ Structure validation: Detects missing required fields
- ✅ Module existence: Finds non-existent modules in marketplace
- ✅ Dependency validation (V2): NEW - Reads dependencies from marketplace dynamically
- ✅ Parameter validation: NEW - Validates parameters against marketplace schemas
- ✅ Conflict detection: Identifies incompatible modules
- ✅ Quality scoring: Provides 0-100 quality score
🚀 Key Features
Dynamic Validation:
- ✅ Reads actual dependencies from marketplace manifests
- ✅ No hardcoded rules - always in sync with marketplace
- ✅ Works with any marketplace (official or custom)
- ✅ Supports third-party and private company marketplaces
Parameter Validation:
- ✅ Validates parameter types (string, boolean, number, object, array)
- ✅ Validates enum/options values
- ✅ Checks required parameters
- ✅ Warns about unknown parameters
Marketplace-Agnostic:
- ✅ Default: Uses
@thearchitech.xyz/marketplace - ✅ Custom: Pass
marketplacePathoption for any marketplace
Installation
npm install @thearchitech.xyz/validatorUsage
Simple Validation
import { validateGenome } from '@thearchitech.xyz/validator';
const genome = {
version: '1.0.0',
project: {
name: 'my-app',
framework: 'nextjs'
},
modules: [
{ id: 'framework/nextjs' },
{ id: 'database/drizzle' }
]
};
const result = await validateGenome(genome);
if (result.isValid) {
console.log('✅ Genome is valid! Score:', result.score);
} else {
console.error('❌ Validation errors:');
result.errors.forEach(error => {
console.error(` - ${error.message}`);
if (error.fix) console.error(` Fix: ${error.fix}`);
});
}Custom Marketplace Validation
import { validateGenome } from '@thearchitech.xyz/validator';
// Validate with custom/third-party marketplace
const result = await validateGenome(genome, {
marketplacePath: '/path/to/custom/marketplace'
});
// Or using GenomeValidator class
import { GenomeValidator } from '@thearchitech.xyz/validator';
const validator = new GenomeValidator(undefined, {
marketplacePath: '/path/to/my-company-marketplace',
enableParameterValidation: true
});
const result = await validator.validate(genome);Detailed Result
{
isValid: true,
errors: [],
warnings: [],
score: 100,
metadata: {
modulesValidated: 3,
rulesApplied: 4,
executionTime: 2
}
}Validation Rules
The validator checks:
- ✅ Structure - Valid Genome interface
- ✅ Module Existence - All module IDs exist in marketplace
- ✅ Dependencies - Required dependencies are present
- ✅ Conflicts - No conflicting modules
- ✅ Parameters - Required parameters are provided
- ✅ File Ownership - Modules only modify files they own
API
validateGenome(genome: Genome): ValidationResult
Main validation function.
Returns:
{
isValid: boolean;
errors: ValidationError[];
warnings: ValidationWarning[];
score?: number; // Optional quality score 0-100
}GenomeValidator
Class-based validator for advanced usage:
import { GenomeValidator } from '@thearchitech.xyz/validator';
const validator = new GenomeValidator();
const result = await validator.validate(genome);
// Add custom validation rules
validator.addRule({
name: 'custom-rule',
description: 'My custom validation',
async validate(genome) {
const errors = [];
const warnings = [];
// Your validation logic here
if (!genome.project.description) {
warnings.push({
type: 'MISSING_RECOMMENDED',
message: 'Project description is recommended',
suggestion: 'Add a description to help users understand your project'
});
}
return { errors, warnings };
}
});Examples
Example 1: Valid Genome (Score: 100/100)
const validGenome = {
version: '1.0.0',
project: {
name: 'hello-world',
framework: 'nextjs'
},
modules: [
{ id: 'framework/nextjs' },
{ id: 'ui/shadcn-ui' }
]
};
// Result: isValid = true, score = 100Example 2: Missing Dependencies
const brokenGenome = {
version: '1.0.0',
project: {
name: 'auth-app',
framework: 'nextjs'
},
modules: [
{ id: 'features/auth/frontend/shadcn' }
// ❌ Missing: auth adapter and database
]
};
// Result:
// - Error: "Module requires a auth module"
// - Error: "Module requires a database module"Example 3: Conflicting Modules
const conflictGenome = {
version: '1.0.0',
project: {
name: 'multi-db',
framework: 'nextjs'
},
modules: [
{ id: 'database/drizzle' },
{ id: 'database/prisma' }
// ❌ Conflict: Only one ORM allowed
]
};
// Result:
// - Error: "Conflicting modules detected: database/drizzle, database/prisma"License
MIT
