{"id":26821550,"url":"https://github.com/mattlean/checkpointjs","last_synced_at":"2026-05-17T08:34:58.873Z","repository":{"id":41798467,"uuid":"169834699","full_name":"mattlean/checkpointjs","owner":"mattlean","description":"Data validation \u0026 transformation library","archived":false,"fork":false,"pushed_at":"2023-01-03T16:39:54.000Z","size":1048,"stargazers_count":0,"open_issues_count":17,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-19T13:18:13.693Z","etag":null,"topics":["checkpointjs","javascript","library","sanitization","transformation","typescript","validation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mattlean.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-09T05:18:26.000Z","updated_at":"2020-09-05T12:47:01.000Z","dependencies_parsed_at":"2023-02-01T08:01:46.498Z","dependency_job_id":null,"html_url":"https://github.com/mattlean/checkpointjs","commit_stats":null,"previous_names":["isaaclean/checkpointjs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mattlean/checkpointjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fcheckpointjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fcheckpointjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fcheckpointjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fcheckpointjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattlean","download_url":"https://codeload.github.com/mattlean/checkpointjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattlean%2Fcheckpointjs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260756809,"owners_count":23057949,"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","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":["checkpointjs","javascript","library","sanitization","transformation","typescript","validation"],"created_at":"2025-03-30T07:31:17.927Z","updated_at":"2026-05-17T08:34:53.851Z","avatar_url":"https://github.com/mattlean.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**THIS LIBRARY IS CURRENTLY UNSTABLE! USE AT YOUR OWN RISK!**\n\n# Checkpoint.js\nValidate and transform data.\n\n## Setup\n### Download\nInstall the [`checkpointjs` package](https://npmjs.com/package/checkpointjs) with a package manager like npm or Yarn.\n\nYou can also download and extract a release from here from the [Checkpoint.js GitHub repository releases page](https://github.com/IsaacLean/checkpointjs/releases).\n\n### Using the Library\nThe library can be used in two different ways:\n\n#### Direct Function Import\n```javascript\nimport { validate } from 'checkpointjs'\n\nconst data = {\n  foo: 'bar',\n  123: 456\n}\n\nconst result = validate(data, {\n  schema: {\n    foo: { isRequired: true, type: 'string' },\n    123: { type: 'number' }\n  },\n  type: 'object'\n})\n```\n\n#### Checkpoint Instantiation\n```javascript\nimport checkpoint from 'checkpointjs'\n\nconst data = {\n  foo: 'bar',\n  123: 456\n}\n\nconst result = checkpoint(data).validate({\n  schema: {\n    foo: { isRequired: true, type: 'string' },\n    123: { type: 'number' }\n  },\n  type: 'object'\n})\n```\n\n*Note: This library supports TypeScript. The source is completely written in it. Declaration files are included in the `dist/` folder.*\n\n## API\n### Validate\nValidates the input data. Returns the results of the validation.\n\n#### Functions\n```javascript\n// Direct Function Import\nvalidate(data, rules)\n\n// Checkpoint Instantiation\ncheckpoint(data).validate(rules)\n```\n\n#### Result\n*TODO*\n\n#### Schema\n##### allowNull\n- Description: Determines if a null value is allowed.\n- Type: `boolean`\n- Default: `false`\n\n```javascript\n// Primitive\nconst primitiveData = null\nconst primitiveValidationResult = validate(primitiveData, {\n  schema: { allowNull: true },\n  type: 'primitive'\n})\nconsole.log(primitiveValidationResult.pass) // true\n\n// Object\nconst objectData = { foo: null }\nconst objectValidationResult = validate(objectData, {\n  schema: {\n    foo: { allowNull: true }\n  },\n  type: 'object'\n})\nconsole.log(objectValidationResult.pass) // true\n\n// Array of primitives\nconst primitiveArrayData = [null, null]\nconst primitiveArrayValidationResult = validate(primitiveArrayData, {\n  schema: { allowNull: true },\n  type: 'array',\n  arrayType: 'primitive'\n})\nconsole.log(primitiveArrayValidationResult.pass) // true\n\n// Array of objects\nconst objectArrayData = [\n  { foo: null },\n  { foo: null }\n]\nconst objectArrayValidationResult = validate(objectArrayData, {\n  schema: { allowNull: true },\n  type: 'array',\n  arrayType: 'object'\n})\nconsole.log(objectArrayValidationResult.pass) // true\n```\n\n##### isRequired\n- Description: Determines if the value is required.\n- Type: `boolean`\n- Default: `false`\n\n```javascript\n// Primitive\nconst primitiveData = 123\nconst primitiveValidationResult = validate(primitiveData, {\n  schema: { isRequired: true },\n  type: 'primitive'\n})\nconsole.log(primitiveValidationResult.pass) // true\n\n// Object\nconst objectData = { foo: 123 }\nconst objectValidationResult = validate(objectData, {\n  schema: {\n    foo: { isRequired: true }\n  },\n  type: 'object'\n})\nconsole.log(objectValidationResult.pass) // true\n\n// Array of primitives\nconst primitiveArrayData = [123, 456]\nconst primitiveArrayValidationResult = validate(primitiveArrayData, {\n  schema: { isRequired: true },\n  type: 'array',\n  arrayType: 'primitive'\n})\nconsole.log(primitiveArrayValidationResult.pass) // true\n\n// Array of objects\nconst objectArrayData = [\n  { foo: 123 },\n  { foo: 456 }\n]\nconst objectArrayValidationResult = validate(objectArrayData, {\n  schema: { isRequired: true },\n  type: 'array',\n  arrayType: 'object'\n})\nconsole.log(objectArrayValidationResult.pass) // true\n```\n\n##### stringValidation\n*TODO*\n\n##### type\n- Description: Requires a matching type for the value.\n- Type: `string`\n\n```javascript\n// Primitive\nconst primitiveData = 'foo'\nconst primitiveValidationResult = validate(primitiveData, {\n  schema: { type: 'string' },\n  type: 'primitive'\n})\nconsole.log(primitiveValidationResult.pass) // true\n\n// Object\nconst objectData = { foo: 123 }\nconst objectValidationResult = validate(objectData, {\n  schema: {\n    foo: { type: 'number' }\n  },\n  type: 'object'\n})\nconsole.log(objectValidationResult.pass) // true\n\n// Array of primitives\nconst primitiveArrayData = [true, false]\nconst primitiveArrayValidationResult = validate(primitiveArrayData, {\n  schema: { type: 'boolean' },\n  type: 'array',\n  arrayType: 'primitive'\n})\nconsole.log(primitiveArrayValidationResult.pass) // true\n\n// Array of objects\nconst objectArrayData = [\n  { foo: 'bar' },\n  { foo: 'baz' }\n]\nconst objectArrayValidationResult = validate(objectArrayData, {\n  schema: { type: 'string' },\n  type: 'array',\n  arrayType: 'object'\n})\nconsole.log(objectArrayValidationResult.pass) // true\n```\n\n#### Options\n##### exitASAP\n*TODO*\n\n##### requireMode\n*TODO*\n\n### Transform\nTransforms and mutates the input data. Returns the transformed data.\n\n#### Functions\n```javascript\n// Direct Function Import\ntransform(data, commands)\n\n// Checkpoint Instantiation\ncheckpoint(data).transform(commands)\n```\n\n#### Commands\n##### clean\n- Description: Removes undefined values.\n\n```javascript\n// Object\nconst objectData = { a: 123, b: undefined, c: 456, d: 789, e: undefined }\ntransform(objectData, 'clean')\nconsole.log(objectData) // { a: 123, c: 456, d: 789 }\n```\n\n##### replace\n- Description: Replaces values with another value.\n\n```javascript\n// Object\nconst objectData = { a: 123, b: 456, c: 789 }\ntransform(objectData, { name: 'replace', options: [456, 'xyz'] })\nconsole.log(objectData) // { a: 123, c: 'xyz', d: 789 }\n```\n\n##### trim\n- Description: Trims whitespace from strings.\n\n```javascript\n// Object\nconst objectData = { a: 'hey    ', b: '    ho', c: '     let\\'s go     ' }\ntransform(objectData, 'trim')\nconsole.log(objectData) // { a: 'hey', c: 'ho', d: 'let\\'s go' }\n```\n\n### Checkpoint\n*TODO*\n\n## License\nThis open source project is licensed under the [MIT License](https://github.com/IsaacLean/checkpointjs/blob/master/LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattlean%2Fcheckpointjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattlean%2Fcheckpointjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattlean%2Fcheckpointjs/lists"}