{"_id":"@ambrosia-unce/validator","_rev":"4-541b10308fa4909502154660c2bcd72d","name":"@ambrosia-unce/validator","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@ambrosia-unce/validator","version":"1.0.0","keywords":["ambrosia","validation","type-safe","compile-time","branded-types","bun","typescript"],"author":{"name":"Ambrosia Framework"},"license":"MIT","_id":"@ambrosia-unce/validator@1.0.0","maintainers":[{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"}],"homepage":"https://github.com/ambrosia-unce/ambrosia/tree/master/packages/validator","bugs":{"url":"https://github.com/ambrosia-unce/ambrosia/issues"},"dist":{"shasum":"36e8a3e60517d980d7ca9cf7fe41a8455f63c32a","tarball":"https://registry.npmjs.org/@ambrosia-unce/validator/-/validator-1.0.0.tgz","fileCount":48,"integrity":"sha512-f9uXCQTFongjyUPRXji7a7U/6N51ld4BIr1TGDm/tkd3hsXrNgkn4ktg3FQrrebhjb3F+PohS4Y9ZA+uGu8mnw==","signatures":[{"sig":"MEQCIFq8MI6/1V3vRmWxsUr2l2uNKzi+UnW0eDmd6+hzARexAiBGN8IxHuORRwg8LmEQp9cOaQeKljeLfviuDrAXGz/40g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ambrosia-unce%2fvalidator@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":23388963},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"bun":">=1.3.6"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./types":{"types":"./dist/types/index.d.ts","default":"./dist/types/index.js"},"./plugin":{"types":"./dist/plugin/index.d.ts","default":"./dist/plugin/index.js"},"./preload":"./preload.ts","./runtime":{"types":"./dist/runtime/index.d.ts","default":"./dist/runtime/index.js"}},"gitHead":"d86ee39512a468e7c5413e9c243c07849306455e","scripts":{"test":"echo no tests","build":"bun run build.ts","prepublishOnly":"bun run build"},"_npmUser":{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"},"repository":{"url":"git+https://github.com/ambrosia-unce/ambrosia.git","type":"git","directory":"packages/validator"},"_npmVersion":"10.8.2","description":"Type-safe compile-time validation for Ambrosia framework","directories":{},"_nodeVersion":"20.20.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"peerDependencies":{"typescript":"^5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/validator_1.0.0_1774566993815_0.519731553266976","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@ambrosia-unce/validator","version":"1.0.1","keywords":["ambrosia","validation","type-safe","compile-time","branded-types","bun","typescript"],"author":{"name":"Ambrosia Framework"},"license":"MIT","_id":"@ambrosia-unce/validator@1.0.1","maintainers":[{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"}],"homepage":"https://github.com/ambrosia-unce/ambrosia/tree/master/packages/validator","bugs":{"url":"https://github.com/ambrosia-unce/ambrosia/issues"},"dist":{"shasum":"405b04917d63affb2cfe0c8b0a23ea2b7c88968f","tarball":"https://registry.npmjs.org/@ambrosia-unce/validator/-/validator-1.0.1.tgz","fileCount":48,"integrity":"sha512-/wsbP+EWjP1GD1gaxI6c9A8zuAsj/89ouSPir8EYABB5jsY5mlaATkVSyUxeUi6ibhFMCu6D9tW31TuCUJ/0cQ==","signatures":[{"sig":"MEQCIDkIMmA3ye0EA74DTr/Ks+IHrQyK1HMecDw57B5baJ7KAiAqPEjXoY/NM1Kr6mllk42B6SwYNwH9Ei8xbCL++N3Fiw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ambrosia-unce%2fvalidator@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":23388963},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"bun":">=1.3.6"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./types":{"types":"./dist/types/index.d.ts","default":"./dist/types/index.js"},"./plugin":{"types":"./dist/plugin/index.d.ts","default":"./dist/plugin/index.js"},"./preload":"./preload.ts","./runtime":{"types":"./dist/runtime/index.d.ts","default":"./dist/runtime/index.js"}},"gitHead":"623e54bd30bbb3e8ce80ad7cedb8fd0cd9daf9ee","scripts":{"test":"echo no tests","build":"bun run build.ts","prepublishOnly":"bun run build"},"_npmUser":{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"},"repository":{"url":"git+https://github.com/ambrosia-unce/ambrosia.git","type":"git","directory":"packages/validator"},"_npmVersion":"10.8.2","description":"Type-safe compile-time validation for Ambrosia framework","directories":{},"_nodeVersion":"20.20.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"peerDependencies":{"typescript":"^5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/validator_1.0.1_1774600003113_0.646758053929688","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@ambrosia-unce/validator","version":"1.0.2","keywords":["ambrosia","validation","type-safe","compile-time","branded-types","bun","typescript"],"author":{"name":"Ambrosia Framework"},"license":"MIT","_id":"@ambrosia-unce/validator@1.0.2","maintainers":[{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"}],"homepage":"https://github.com/ambrosia-unce/ambrosia/tree/master/packages/validator","bugs":{"url":"https://github.com/ambrosia-unce/ambrosia/issues"},"dist":{"shasum":"4ff750d7e063ef07a6a42ae70c35ff67a83696c4","tarball":"https://registry.npmjs.org/@ambrosia-unce/validator/-/validator-1.0.2.tgz","fileCount":63,"integrity":"sha512-f6W/8Dli05fP0FmvhYDCMEWOgDAar1tOCH+3sa3pgyHcEWmn8f1s+ZBK3c5CJfzhosXPp8QdQi/N3NQBdA3e0A==","signatures":[{"sig":"MEUCIBk3paW/GaJTI7g08jXHRFcuyz9htHixwaI6ebtZ6nlPAiEA8TvNObtQUrymfz9VrVFP6BTorJtQ2rMaMf4NK5q4vsM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ambrosia-unce%2fvalidator@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":23436916},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"bun":">=1.3.6"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./types":{"types":"./dist/types/index.d.ts","default":"./dist/types/index.js"},"./plugin":{"types":"./dist/plugin/index.d.ts","default":"./dist/plugin/index.js"},"./preload":"./preload.ts","./runtime":{"types":"./dist/runtime/index.d.ts","default":"./dist/runtime/index.js"}},"gitHead":"082d75533110c5adf0142c3923ec825090cb1f2c","scripts":{"test":"echo no tests","build":"bun run build.ts","prepublishOnly":"bun run build"},"_npmUser":{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"},"repository":{"url":"git+https://github.com/ambrosia-unce/ambrosia.git","type":"git","directory":"packages/validator"},"_npmVersion":"10.8.2","description":"Type-safe compile-time validation for Ambrosia framework","directories":{},"_nodeVersion":"20.20.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"peerDependencies":{"typescript":"^5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/validator_1.0.2_1774601010100_0.9160068809691342","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@ambrosia-unce/validator","version":"1.0.3","description":"Type-safe compile-time validation for Ambrosia framework","type":"module","license":"MIT","author":{"name":"Ambrosia Framework"},"homepage":"https://github.com/ambrosia-unce/ambrosia/tree/master/packages/validator","repository":{"type":"git","url":"git+https://github.com/ambrosia-unce/ambrosia.git","directory":"packages/validator"},"bugs":{"url":"https://github.com/ambrosia-unce/ambrosia/issues"},"keywords":["ambrosia","validation","type-safe","compile-time","branded-types","bun","typescript"],"engines":{"bun":">=1.3.6"},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./plugin":{"types":"./dist/plugin/index.d.ts","default":"./dist/plugin/index.js"},"./preload":"./preload.ts","./types":{"types":"./dist/types/index.d.ts","default":"./dist/types/index.js"},"./runtime":{"types":"./dist/runtime/index.d.ts","default":"./dist/runtime/index.js"}},"scripts":{"build":"bun run build.ts","prepublishOnly":"bun run build","test":"echo no tests"},"peerDependencies":{"typescript":"^5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"publishConfig":{"access":"public"},"dependencies":{},"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"_id":"@ambrosia-unce/validator@1.0.3","gitHead":"9866c0dc1ed4d18da5285d208f4dd815d25ae940","_nodeVersion":"20.20.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-BLl8LIJT/iYzYdb0pf7nq7iiIj45rVDWxAp+A4/Wwrfrmt77jEkGETe5R+934kl6H0KhBGqumyN4j0i6DGikEw==","shasum":"ac764f9d90fa196ead4d69f6b843654d8a6dfa0f","tarball":"https://registry.npmjs.org/@ambrosia-unce/validator/-/validator-1.0.3.tgz","fileCount":48,"unpackedSize":23388982,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ambrosia-unce%2fvalidator@1.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDCxg56C4qPYOuNlaREXN3kI3kFh/e7du16AYccKzpHawIhAKqRqTqfgOOnOhLow5vcuRWhonZfLsYM2wyk6KgvxLbG"}]},"_npmUser":{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"},"directories":{},"maintainers":[{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/validator_1.0.3_1774606933432_0.19506418871813702"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-26T23:16:33.713Z","modified":"2026-03-27T10:22:14.051Z","1.0.0":"2026-03-26T23:16:34.115Z","1.0.1":"2026-03-27T08:26:43.383Z","1.0.2":"2026-03-27T08:43:30.376Z","1.0.3":"2026-03-27T10:22:13.783Z"},"bugs":{"url":"https://github.com/ambrosia-unce/ambrosia/issues"},"author":{"name":"Ambrosia Framework"},"license":"MIT","homepage":"https://github.com/ambrosia-unce/ambrosia/tree/master/packages/validator","keywords":["ambrosia","validation","type-safe","compile-time","branded-types","bun","typescript"],"repository":{"type":"git","url":"git+https://github.com/ambrosia-unce/ambrosia.git","directory":"packages/validator"},"description":"Type-safe compile-time validation for Ambrosia framework","maintainers":[{"name":"funnybunny_unce","email":"funnybunny.unce@gmail.com"}],"readme":"# @ambrosia-unce/validator\n\nType-safe compile-time validation for Ambrosia framework using Bun plugin system and TypeScript Compiler API.\n\n## Features\n\n- ✅ **Zero runtime overhead** - Validation code generated at compile-time\n- ✅ **Type-safe** - Full TypeScript type inference\n- ✅ **No decorators** - Just TypeScript types\n- ✅ **No schema duplication** - Types are the schema\n- ✅ **Branded types** - Email, UUID, PositiveInt, and more\n- ✅ **JSDoc constraints** - @minLength, @pattern, etc.\n- ✅ **Bun native** - Uses Bun plugin system\n\n## Installation\n\n```bash\nbun add @ambrosia-unce/validator\n```\n\n## Setup\n\nAdd to your `bunfig.toml`:\n\n```toml\npreload = [\"@ambrosia-unce/validator/preload\"]\n```\n\nThat's it! The plugin is now active.\n\n## Usage\n\n### Basic validation\n\n```typescript\nimport { validate, assert, is } from '@ambrosia-unce/validator';\n\ninterface User {\n  name: string;\n  email: string;\n  age: number;\n}\n\n// validate<T>() - Returns result object\nconst result = validate<User>(data);\nif (result.success) {\n  console.log(result.data.name);\n} else {\n  console.error(result.errors);\n}\n\n// assert<T>() - Throws on error\ntry {\n  const user = assert<User>(data);\n  console.log(user.name);\n} catch (error) {\n  console.error(error);\n}\n\n// is<T>() - Type guard\nif (is<User>(data)) {\n  // data is User here\n  console.log(data.name);\n}\n```\n\n### Branded types\n\n```typescript\nimport type { Email, UUID, PositiveInt } from '@ambrosia-unce/validator/types';\n\ninterface User {\n  id: UUID;\n  email: Email;\n  age: PositiveInt;\n  name: string;\n}\n\nconst user = assert<User>({\n  id: \"550e8400-e29b-41d4-a716-446655440000\",\n  email: \"user@example.com\",\n  age: 25,\n  name: \"Alice\"\n});\n```\n\nAvailable branded types:\n- `Email` - RFC 5322 email\n- `UUID` - UUID v4\n- `URL` - Valid HTTP/HTTPS URL\n- `PositiveInt` - Integer > 0\n- `NonNegativeInt` - Integer >= 0\n- `DateString` - ISO 8601 date\n- `DateTime` - ISO 8601 datetime\n- `PhoneNumber` - E.164 format\n- `IPv4`, `IPv6` - IP addresses\n- `HexColor` - #RRGGBB or #RGB\n- And more...\n\n### JSDoc constraints\n\n```typescript\ninterface UpdateUserDto {\n  /**\n   * @minLength 3\n   * @maxLength 50\n   * @pattern ^[a-zA-Z0-9_]+$\n   */\n  name?: string;\n\n  /**\n   * @format email\n   */\n  email?: string;\n\n  /**\n   * @minimum 18\n   * @maximum 120\n   */\n  age?: number;\n}\n\nconst dto = assert<UpdateUserDto>(data);\n```\n\n### With Ambrosia HTTP\n\n```typescript\nimport { Controller, Post, Body } from '@ambrosia-unce/http';\nimport { assert } from '@ambrosia-unce/validator';\n\ninterface CreateUserDto {\n  name: string;\n  email: string;\n}\n\n@Controller('/users')\nexport class UserController {\n  @Post('/')\n  async create(@Body() data: unknown) {\n    const dto = assert<CreateUserDto>(data);\n    // dto is validated and typed!\n    return this.userService.create(dto);\n  }\n}\n```\n\n## How it works\n\nThe plugin uses TypeScript Compiler API to:\n\n1. Find all `validate<T>()`, `assert<T>()`, `is<T>()` calls\n2. Analyze the type `T` using TypeScript's type checker\n3. Generate optimized inline validation code\n4. Replace the function call with generated code\n\n### Before transformation:\n\n```typescript\nconst user = assert<User>(data);\n```\n\n### After transformation:\n\n```typescript\nconst user = ((data) => {\n  if (typeof data !== \"object\" || data === null)\n    throw new ValidationError(\"must be an object\");\n  if (typeof data.name !== \"string\")\n    throw new ValidationError(\"name must be string\");\n  if (typeof data.email !== \"string\")\n    throw new ValidationError(\"email must be string\");\n  if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(data.email))\n    throw new ValidationError(\"email must be valid\");\n  if (typeof data.age !== \"number\")\n    throw new ValidationError(\"age must be number\");\n  return data;\n})(data);\n```\n\n## Configuration\n\nCustom plugin options:\n\n```typescript\n// validator-config.ts\nimport { plugin } from \"bun\";\nimport { createValidatorPlugin } from \"@ambrosia-unce/validator/plugin\";\n\nplugin(createValidatorPlugin({\n  debug: true, // Enable debug logging\n  include: /\\.ts$/, // File patterns to include\n  exclude: /node_modules/, // File patterns to exclude\n}));\n```\n\nThen in `bunfig.toml`:\n\n```toml\npreload = [\"./validator-config.ts\"]\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}