{"_rev":"3-1bc7e2ba5fff921a71f8b531f689295d","time":{"created":"2025-08-21T00:47:41.282Z","modified":"2025-08-21T00:47:41.881Z","1.0.0":"2025-08-20T16:11:14.361Z","1.0.1":"2025-08-21T00:47:41.618Z"},"_id":"@codechu/flow-core-validation","name":"@codechu/flow-core-validation","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@codechu/flow-core-validation","version":"1.0.1","type":"module","description":"Flow ecosystem validation abstractions - Pure interfaces for input/output validation with zero logic","keywords":["flow","validation","typescript","functional","result-pattern","interfaces","core","abstractions"],"author":{"name":"Codechu - Obarlik"},"license":"MIT","homepage":"https://github.com/codechu/flow-core-validation#readme","repository":{"type":"git","url":"git+https://github.com/codechu/flow-core-validation.git"},"bugs":{"url":"https://github.com/codechu/flow-core-validation/issues"},"main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"engines":{"node":">=18.0.0"},"scripts":{"build":"tsc","test":"node --test","type-check":"tsc --noEmit","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build && npm test"},"dependencies":{"@codechu/flow-core-seed":"^1.0.0"},"devDependencies":{"@types/node":"^22.5.0","typescript":"^5.5.4"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_id":"@codechu/flow-core-validation@1.0.1","gitHead":"da8c57a9e3d13aeb13299ceff6b0d894b03ddab2","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-vyAUG8dduUxkNHktTySA2/bAk8EmSgnxRhvw17ujLE4XLQwHP0tS/CsD95FkiCrE85+lLI37ljCgUPxIZoI6Xw==","shasum":"9a571d467759245e1e7a1e969b6555352848a1cd","tarball":"https://registry.npmjs.org/@codechu/flow-core-validation/-/flow-core-validation-1.0.1.tgz","fileCount":8,"unpackedSize":28097,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDekOi0CTzfdvuT8y3RITIflIyvW3Dq8kPt5pNVF8dN/QIgCRQ2kJ1V+927vd1l/ZydugSySipXjrurEvD3REWOi/8="}]},"_npmUser":{"name":"obarlik","email":"onurbarlik@gmail.com"},"directories":{},"maintainers":[{"name":"obarlik","email":"onurbarlik@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/flow-core-validation_1.0.1_1755737261372_0.23920196857628118"},"_hasShrinkwrap":false}},"maintainers":[{"name":"obarlik","email":"onurbarlik@gmail.com"}],"description":"Flow ecosystem validation abstractions - Pure interfaces for input/output validation with zero logic","homepage":"https://github.com/codechu/flow-core-validation#readme","keywords":["flow","validation","typescript","functional","result-pattern","interfaces","core","abstractions"],"repository":{"type":"git","url":"git+https://github.com/codechu/flow-core-validation.git"},"author":{"name":"Codechu - Obarlik"},"bugs":{"url":"https://github.com/codechu/flow-core-validation/issues"},"license":"MIT","readme":"# 🛡️ Flow Core Validation\r\n\r\n[![npm version](https://badge.fury.io/js/@codechu%2Fflow-core-validation.svg)](https://badge.fury.io/js/@codechu%2Fflow-core-validation)\r\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\n**Pure validation abstractions for the Flow ecosystem** - Zero implementation, maximum flexibility through interfaces.\r\n\r\n## 🎯 **Core Philosophy**\r\n\r\nFlow Core Validation provides **ONLY interfaces and types** - no implementation logic. This enables unlimited validation approaches while maintaining type safety and Flow ecosystem compatibility.\r\n\r\n```typescript\r\nimport { IFlowValidator, FlowResult } from '@codechu/flow-core-validation';\r\nimport { IFlowContext, success, failure } from '@codechu/flow-core-seed';\r\n\r\n// Your implementation, your rules - just follow the interface\r\nclass EmailValidator implements IFlowValidator<string, string> {\r\n  readonly id = 'email-validator';\r\n  readonly name = 'Email Validation';\r\n  \r\n  async validate(input: string, context: IFlowContext): Promise<FlowResult<string>> {\r\n    const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\r\n    return emailRegex.test(input) \r\n      ? success(input.toLowerCase())\r\n      : failure(flowError('INVALID_EMAIL', 'Invalid email format'));\r\n  }\r\n}\r\n```\r\n\r\n## 📦 **Installation**\r\n\r\n```bash\r\nnpm install @codechu/flow-core-validation\r\n```\r\n\r\n## 🏗️ **Core Interfaces**\r\n\r\n### **IFlowValidator<TInput, TOutput>**\r\nUniversal validation interface for any data type:\r\n\r\n```typescript\r\ninterface IFlowValidator<TInput, TOutput = TInput> {\r\n  readonly id: string;\r\n  readonly name: string;\r\n  readonly description?: string;\r\n  \r\n  validate(input: TInput, context: IFlowContext): Promise<FlowResult<TOutput>>;\r\n}\r\n```\r\n\r\n### **IFlowSchema<TInput, TOutput>**\r\nSchema-based validation with metadata:\r\n\r\n```typescript\r\ninterface IFlowSchema<TInput, TOutput = TInput> {\r\n  readonly id: string;\r\n  readonly name: string;\r\n  readonly version?: string;\r\n  \r\n  validateSchema(input: TInput, context: IFlowContext): Promise<FlowResult<TOutput>>;\r\n  getSchemaRules(): Record<string, unknown>;\r\n}\r\n```\r\n\r\n### **IFlowValidationPipeline<TInput, TOutput>**\r\nChain validators together:\r\n\r\n```typescript\r\ninterface IFlowValidationPipeline<TInput, TOutput = TInput> {\r\n  readonly id: string;\r\n  readonly name: string;\r\n  \r\n  addValidator<TNext>(validator: IFlowValidator<TOutput, TNext>): IFlowValidationPipeline<TInput, TNext>;\r\n  validatePipeline(input: TInput, context: IFlowContext): Promise<FlowResult<TOutput>>;\r\n  getPipelineInfo(): { validatorCount: number; validatorIds: string[]; };\r\n}\r\n```\r\n\r\n### **IFlowConditionalValidator<TInput, TOutput>**\r\nApply validation conditionally:\r\n\r\n```typescript\r\ninterface IFlowConditionalValidator<TInput, TOutput = TInput> {\r\n  readonly id: string;\r\n  readonly name: string;\r\n  \r\n  shouldValidate(input: TInput, context: IFlowContext): Promise<boolean>;\r\n  validateConditionally(input: TInput, context: IFlowContext): Promise<FlowResult<TOutput>>;\r\n}\r\n```\r\n\r\n## 🛠️ **Usage Examples**\r\n\r\n### **Basic Validator Implementation**\r\n\r\n```typescript\r\nimport { IFlowValidator, FlowResult } from '@codechu/flow-core-validation';\r\nimport { success, failure, flowError } from '@codechu/flow-core-seed';\r\n\r\nclass NumberRangeValidator implements IFlowValidator<number, number> {\r\n  constructor(private min: number, private max: number) {}\r\n  \r\n  readonly id = `range-${this.min}-${this.max}`;\r\n  readonly name = `Number Range Validator (${this.min}-${this.max})`;\r\n  \r\n  async validate(input: number, context: IFlowContext): Promise<FlowResult<number>> {\r\n    if (input >= this.min && input <= this.max) {\r\n      return success(input);\r\n    }\r\n    \r\n    return failure(flowError(\r\n      'OUT_OF_RANGE',\r\n      `Number ${input} not in range ${this.min}-${this.max}`,\r\n      new RangeError(`Expected ${this.min}-${this.max}, got ${input}`)\r\n    ));\r\n  }\r\n}\r\n```\r\n\r\n### **Schema Validation**\r\n\r\n```typescript\r\nimport { IFlowSchema } from '@codechu/flow-core-validation';\r\n\r\ninterface UserData {\r\n  name: string;\r\n  email: string;\r\n  age: number;\r\n}\r\n\r\nclass UserSchema implements IFlowSchema<unknown, UserData> {\r\n  readonly id = 'user-schema';\r\n  readonly name = 'User Data Schema';\r\n  readonly version = '1.0.0';\r\n  \r\n  async validateSchema(input: unknown, context: IFlowContext): Promise<FlowResult<UserData>> {\r\n    // Your schema validation logic here\r\n    // Could use Zod, Joi, or custom validation\r\n    return success(input as UserData);\r\n  }\r\n  \r\n  getSchemaRules() {\r\n    return {\r\n      type: 'object',\r\n      properties: {\r\n        name: { type: 'string', required: true },\r\n        email: { type: 'string', format: 'email', required: true },\r\n        age: { type: 'number', minimum: 0, maximum: 150 }\r\n      }\r\n    };\r\n  }\r\n}\r\n```\r\n\r\n### **Validation Pipeline**\r\n\r\n```typescript\r\nimport { IFlowValidationPipeline } from '@codechu/flow-core-validation';\r\n\r\nclass StringValidationPipeline implements IFlowValidationPipeline<string, string> {\r\n  readonly id = 'string-pipeline';\r\n  readonly name = 'String Validation Pipeline';\r\n  private validators: IFlowValidator<any, any>[] = [];\r\n  \r\n  addValidator<TNext>(validator: IFlowValidator<string, TNext>) {\r\n    this.validators.push(validator);\r\n    return this as any; // Type casting for chaining\r\n  }\r\n  \r\n  async validatePipeline(input: string, context: IFlowContext): Promise<FlowResult<string>> {\r\n    let current: any = input;\r\n    \r\n    for (const validator of this.validators) {\r\n      const result = await validator.validate(current, context);\r\n      if (!result.isSuccess) {\r\n        return result;\r\n      }\r\n      current = result.value;\r\n    }\r\n    \r\n    return success(current);\r\n  }\r\n  \r\n  getPipelineInfo() {\r\n    return {\r\n      validatorCount: this.validators.length,\r\n      validatorIds: this.validators.map(v => v.id)\r\n    };\r\n  }\r\n}\r\n\r\n// Usage\r\nconst pipeline = new StringValidationPipeline()\r\n  .addValidator(new TrimValidator())\r\n  .addValidator(new EmailValidator())\r\n  .addValidator(new LowercaseValidator());\r\n```\r\n\r\n## 🏗️ **Advanced Features**\r\n\r\n### **Conditional Validation**\r\n\r\n```typescript\r\nclass ConditionalEmailValidator implements IFlowConditionalValidator<string, string> {\r\n  readonly id = 'conditional-email';\r\n  readonly name = 'Conditional Email Validator';\r\n  \r\n  async shouldValidate(input: string, context: IFlowContext): Promise<boolean> {\r\n    // Only validate if input looks like it might be an email\r\n    return input.includes('@');\r\n  }\r\n  \r\n  async validateConditionally(input: string, context: IFlowContext): Promise<FlowResult<string>> {\r\n    if (await this.shouldValidate(input, context)) {\r\n      return new EmailValidator().validate(input, context);\r\n    }\r\n    return success(input); // Pass through unchanged\r\n  }\r\n}\r\n```\r\n\r\n### **Validation Context with History**\r\n\r\n```typescript\r\nimport { IFlowValidationContext } from '@codechu/flow-core-validation';\r\n\r\n// Enhanced context with validation tracking\r\nconst validationContext: IFlowValidationContext = {\r\n  ...flowContext,\r\n  validationData: new Map([\r\n    ['skipWarnings', true],\r\n    ['strictMode', false]\r\n  ]),\r\n  validationHistory: [],\r\n  validationOptions: {\r\n    stopOnFirstError: true,\r\n    includeWarnings: false,\r\n    timeoutMs: 5000\r\n  }\r\n};\r\n```\r\n\r\n### **Type-Safe Utilities**\r\n\r\n```typescript\r\nimport { ValidatorInput, ValidatorOutput, FlowValidationFn } from '@codechu/flow-core-validation';\r\n\r\n// Extract types from validators\r\ntype EmailInput = ValidatorInput<EmailValidator>; // string\r\ntype EmailOutput = ValidatorOutput<EmailValidator>; // string\r\n\r\n// Functional validation approach\r\nconst validateAge: FlowValidationFn<number, number> = async (age, context) => {\r\n  return age >= 18 && age <= 120\r\n    ? success(age)\r\n    : failure(flowError('INVALID_AGE', 'Age must be 18-120'));\r\n};\r\n```\r\n\r\n## 🧪 **Implementation Packages**\r\n\r\nFlow Core Validation is **interface-only**. Use these implementation packages:\r\n\r\n- **`@codechu/flow-joi-validation`** - Joi schema validation\r\n- **`@codechu/flow-zod-validation`** - Zod schema validation  \r\n- **`@codechu/flow-yup-validation`** - Yup schema validation\r\n- **`@codechu/flow-custom-validation`** - Custom validation utilities\r\n\r\n```typescript\r\n// Example with Joi implementation\r\nimport { JoiValidator } from '@codechu/flow-joi-validation';\r\nimport * as Joi from 'joi';\r\n\r\nconst userValidator = new JoiValidator(\r\n  Joi.object({\r\n    name: Joi.string().required(),\r\n    email: Joi.string().email().required(),\r\n    age: Joi.number().min(18).max(120)\r\n  })\r\n);\r\n```\r\n\r\n## ✨ **Key Benefits**\r\n\r\n1. **🎯 Pure Abstractions** - Zero implementation logic, maximum flexibility\r\n2. **🔗 Flow Integration** - Seamless integration with Flow ecosystem\r\n3. **⚡ Type Safety** - Full TypeScript support with generics\r\n4. **🧩 Composability** - Chain, conditional, and pipeline validation\r\n5. **📏 Result Pattern** - Consistent error handling without exceptions\r\n6. **🔒 Immutable Contracts** - Interfaces will never change\r\n7. **🚀 Performance** - Minimal overhead, your implementation rules\r\n\r\n## 🔗 **Flow Ecosystem Integration**\r\n\r\n```typescript\r\nimport { IFlowStep } from '@codechu/flow-core-seed';\r\nimport { IFlowValidator } from '@codechu/flow-core-validation';\r\n\r\n// Validation as a Flow Step\r\nclass ValidationStep<T> implements IFlowStep<T, T> {\r\n  constructor(private validator: IFlowValidator<T>) {}\r\n  \r\n  readonly id = `validation-${this.validator.id}`;\r\n  readonly name = `Validation: ${this.validator.name}`;\r\n  \r\n  async process(input: T, context: IFlowContext): Promise<FlowResult<T>> {\r\n    return this.validator.validate(input, context);\r\n  }\r\n}\r\n```\r\n\r\n## 📊 **Package Stats**\r\n\r\n- **Dependencies**: 1 (`@codechu/flow-core-seed`)\r\n- **Bundle Size**: ~3KB (interfaces only)\r\n- **TypeScript**: Full declaration support\r\n- **Node.js**: >=18.0.0\r\n- **License**: MIT\r\n\r\n## 🌊 **Flow Ecosystem**\r\n\r\nFlow Core Validation is part of the Flow ecosystem:\r\n\r\n- **`@codechu/flow-core-seed`** - Foundation interfaces ✅\r\n- **`@codechu/flow-core-validation`** - Validation abstractions ✅\r\n- **`@codechu/flow-core-container`** - IoC container interfaces\r\n- **`@codechu/flow-core-config`** - Configuration management\r\n- **`@codechu/flow-core-events`** - Event system abstractions\r\n- **`@codechu/flow-core-workflow`** - Workflow orchestration\r\n\r\n## 🏢 **Credits**\r\n\r\n**Company**: Codechu  \r\n**Author**: Obarlik  \r\n**License**: MIT\r\n\r\n---\r\n\r\n🛡️→⚡ **Pure validation interfaces that grow with your needs**// Test deploy key bypass fix\n// Final automated release test\n","readmeFilename":"README.md"}