{"id":31776749,"url":"https://github.com/mamedul/chain-schema-validator","last_synced_at":"2025-10-10T05:55:28.421Z","repository":{"id":313737421,"uuid":"1052414342","full_name":"mamedul/chain-schema-validator","owner":"mamedul","description":"The perfect, feature-complete, chainable schema-based object validator for Node.js and browsers. Inspired by Joi.","archived":false,"fork":false,"pushed_at":"2025-09-08T05:18:38.000Z","size":290,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-08T07:07:27.607Z","etag":null,"topics":["assert","async","chainable","conditional","creditcard","ip","joi","keys","object-validation","perfect-validator","schema","switch","transform","uuid","validation","validator"],"latest_commit_sha":null,"homepage":"http://mamedul.ddns.net/chain-schema-validator/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mamedul.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-08T02:46:21.000Z","updated_at":"2025-09-08T05:18:42.000Z","dependencies_parsed_at":"2025-09-08T16:30:39.162Z","dependency_job_id":null,"html_url":"https://github.com/mamedul/chain-schema-validator","commit_stats":null,"previous_names":["mamedul/chain-schema-validator"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mamedul/chain-schema-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fchain-schema-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fchain-schema-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fchain-schema-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fchain-schema-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mamedul","download_url":"https://codeload.github.com/mamedul/chain-schema-validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamedul%2Fchain-schema-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002863,"owners_count":26083468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","async","chainable","conditional","creditcard","ip","joi","keys","object-validation","perfect-validator","schema","switch","transform","uuid","validation","validator"],"created_at":"2025-10-10T05:55:26.954Z","updated_at":"2025-10-10T05:55:28.408Z","avatar_url":"https://github.com/mamedul.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chain Schema Validator - The Perfect Schema Validation\n\n**The perfect, feature-complete, chainable schema-based object validator for Node.js and browsers. Inspired by Joi, rebuilt for ultimate power and flexibility with zero dependencies.**\n\nThis is the definitive version of `chain-schema-validator`, designed to handle virtually any validation scenario you can imagine. It provides an expressive, fluent API to define schemas, transform data, and validate complex objects with ease.\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://wa.me/8801847406830?text=Hi%2C%20do%20you%20have%20time%20to%20develop%20or%20update%20my%20website%3F\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/mamedul/chain-schema-validator/main/chain-schema-validator-banner.png\" alt=\"Contact\" width=\"1000\" height=\"327\" style=\"width: 100%; height: auto;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Key Features\n\n*   **Massive \u0026 Comprehensive API:** A huge library of validation methods for every data type.\n    \n*   **Powerful Data Transformation:** A dedicated pipeline for sanitizing, formatting, and setting defaults on your data _before_ validation.\n    \n*   **Advanced Conditional \u0026 Relational Logic:** Define complex cross-field dependencies with rules like `when`, `with`, and `switch`\\-like logic using `keys`.\n    \n*   **Deeply Nested Validation:** Effortlessly validate complex nested objects and arrays.\n    \n*   **Asynchronous Support:** Built-in async capabilities for tasks like database lookups.\n    \n*   **Zero Dependencies:** Lightweight, fast, and secure.\n    \n\n## Quick Start\n\nDefine individual field schemas, then compose them into an object schema.\n\n```javascript\nconst { schema, ref } = require('chain-schema-validator');\n\n// 1. Define schemas for individual fields\nconst usernameSchema = schema.string()\n    .trim()\n    .lowercase()\n    .token()\n    .min(3)\n    .required();\n\nconst passwordSchema = schema.string()\n    .min(8)\n    .required();\n\n// 2. Compose into an object schema\nconst registrationSchema = schema.object({\n    username: usernameSchema,\n    email: schema.string().email().required(),\n    password: passwordSchema,\n    passwordConfirm: schema.string().valid(ref('password')).required().strip(),\n    role: schema.string().default('user'),\n    birthYear: schema.number().integer().min(1920).max(2015)\n}, {\n    abortEarly: false // Report all errors\n});\n\n// 3. Validate your data\nconst userData = {\n    username: '  TEST_USER ',\n    email: 'test@example.com',\n    password: 'password123',\n    passwordConfirm: 'password123',\n    birthYear: 1990\n};\n\nconst { value, error } = registrationSchema.validate(userData);\n\nif (error) {\n    console.error('❌ Validation failed:', error.details);\n} else {\n    console.log('✅ Validation passed!');\n    console.log('Sanitized Value:', value);\n    /*\n      Expected output:\n      ✅ Validation passed!\n      Sanitized Value: {\n        username: 'test_user',\n        email: 'test@example.com',\n        password: 'password123',\n        role: 'user',\n        birthYear: 1990\n      }\n    */\n}\n```\n\n## API Reference (Overview)\n\n### Schema Types\n\n*   `schema.string()`\n    \n*   `schema.number()`\n    \n*   `schema.boolean()`\n    \n*   `schema.array()`\n    \n*   `schema.object(schemaMap, options)`\n    \n*   `schema.date()`\n    \n*   `schema.any()`\n    \n\n### 🟢 General / Utility Methods\n\n*   **State Modifiers:** `.required()`, `.optional()`, `.nullable()`, `.forbidden()`, `.strip()`\n    \n*   **Defaults \u0026 Values:** `.default(value)`, `.valid(...values)`, `.invalid(...values)`\n    \n*   **Custom Logic:** `.transform(fn)`, `.custom(fn)`, `.customAsync(fn)`\n    \n*   **Schema Composition:** `.concat(schema)`, `.meta(info)`\n    \n\n### 🟢 String-Specific Methods\n\n*   **Transformation:** `.trim()`, `.lowercase()`, `.uppercase()`\n    \n*   **Validation:** `.min(len)`, `.max(len)`, `.length(len)`, `.pattern(regex)`, `.creditCard()`, `.email()`, `.ip4()`, `.ip6()`, `.ip()`, `.uuid()`, `.hex()`, `.token()`, `.isoDate()`\n    \n\n### 🟢 Number-Specific Methods\n\n*   `.min(val)`, `.max(val)`, `.greater(val)`, `.less(val)`, `.integer()`, `.positive()`, `.negative()`, `.port()`\n    \n\n### 🟢 Array-Specific Methods\n\n*   `.min(len)`, `.max(len)`, `.length(len)`, `.items(schema)`, `.unique()`, `.has(schema)`, `.single()`\n    \n\n### 🟢 Object-Specific Methods\n\n*   `schema.object({ key: schema, ... })` is the primary method.\n    \n*   **Options:** `{ abortEarly: boolean, stripUnknown: boolean }`\n    \n\n## Contributing\n\nThis library is now feature-complete and in a stable state. Bug reports are welcome. Please see our [Security Policy](./SECURITY.md \"null\").\n\nIf you need just object validator, then you can see  [objectPropValidator](https://github.com/mamedul/objectpropvalidator \"null\").\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE \"null\") file for details.\n\n## Author\n\nThis packages codes was created by [**Mamedul Islam**](https://mamedul.github.io/ \"null\") and open for contribute.\n\n_As a passionate **web developer** with experience in creating interactive and user-friendly web components. Currently *available for freelance projects* or full-time opportunities._\n\n_Helping businesses grow their online presence with custom web solutions. Specializing in **WordPress**, **WooCommerce**, **NodeJS**, and **Shopify**. Building modern, responsive, and high-performance scalable websites with custom made plugins, codes, customizations._\n\n\n## Changelog\n\nPlease see the [CHANGELOG.md](CHANGELOG.md \"null\") file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamedul%2Fchain-schema-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmamedul%2Fchain-schema-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamedul%2Fchain-schema-validator/lists"}