{"id":25631043,"url":"https://github.com/natiginfo/checkpoint","last_synced_at":"2025-04-14T16:52:50.340Z","repository":{"id":45114297,"uuid":"248285985","full_name":"natiginfo/Checkpoint","owner":"natiginfo","description":"🛂 An easy to use input validator ✅","archived":false,"fork":false,"pushed_at":"2024-09-06T06:37:22.000Z","size":323,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T04:41:41.310Z","etag":null,"topics":["checkpoint","dsl","java","kotlin","kotlin-dsl","validator"],"latest_commit_sha":null,"homepage":"https://www.natigbabayev.com/Checkpoint","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/natiginfo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-18T16:34:34.000Z","updated_at":"2024-09-06T06:37:25.000Z","dependencies_parsed_at":"2022-08-31T05:10:56.652Z","dependency_job_id":null,"html_url":"https://github.com/natiginfo/Checkpoint","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natiginfo%2FCheckpoint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natiginfo%2FCheckpoint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natiginfo%2FCheckpoint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natiginfo%2FCheckpoint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natiginfo","download_url":"https://codeload.github.com/natiginfo/Checkpoint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248922514,"owners_count":21183942,"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":["checkpoint","dsl","java","kotlin","kotlin-dsl","validator"],"created_at":"2025-02-22T20:18:25.206Z","updated_at":"2025-04-14T16:52:50.318Z","avatar_url":"https://github.com/natiginfo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CodeFactor](https://www.codefactor.io/repository/github/natiginfo/checkpoint/badge)](https://www.codefactor.io/repository/github/natiginfo/checkpoint)\n![Snapshot CI](https://github.com/natiginfo/Checkpoint/workflows/Snapshot%20CI/badge.svg?branch=master)\n\n# Checkpoint\n\nMultipurpose and customizable validation library.\n\n## Getting started\n\n### Download\n\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.natigbabayev.checkpoint\u003c/groupId\u003e\n  \u003cartifactId\u003echeckpoint-core\u003c/artifactId\u003e\n  \u003cversion\u003e0.6.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003c!-- Optional RxJava 2 support: --\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.natigbabayev.checkpoint\u003c/groupId\u003e\n  \u003cartifactId\u003echeckpoint-rxjava2\u003c/artifactId\u003e\n  \u003cversion\u003e0.6.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle:\n\nCore:\n```groovy\nimplementation 'com.natigbabayev.checkpoint:checkpoint-core:0.6.0'\n// Optional RxJava 2 support:\nimplementation 'com.natigbabayev.checkpoint:checkpoint-rxjava2:0.6.0'\n```\n\nSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap].\n\n### Usage\n\nCheckpoint allows you to perform validation checks for given input. [`Checkpoint`][checkpoint] is generic collection of \n[rules with boolean output][default-rule]. You can create a new instance of Checkpoint either by using builder or DSL:\n\n#### DSL\n\n```kotlin\nfun main() {\n    val pinCheckpoint = checkpoint\u003cCharSequence\u003e {\n        addRule(\n            lengthRangeRule(minLength = 4, maxLength = 6) {\n                println(\"Must contain min. 4, max 6 characters\")\n            }\n        )\n        addRule {\n            isValid { it.contains(\"@\") || it.contains(\"!\") }\n            whenInvalid { println(\"Must contain at least one of the @ or ! characters.\") }\n        }\n    }\n\n    pinCheckpoint.canPass(\"123\") // returns false and invokes whenInvalid()\n    pinCheckpoint.canPass(\"1234\") // returns false and invokes whenInvalid()\n    pinCheckpoint.canPass(\"1234@6!\") // returns false and invokes whenInvalid()\n    pinCheckpoint.canPass(\"1234@6\") // returns true\n}\n```\n\n#### Builder\n\n```kotlin\nfun main() {\n    val pinCheckpoint = Checkpoint.Builder\u003cCharSequence\u003e()\n        .addRule(\n            LengthRangeRule.Builder()\n                .minLength(4)\n                .maxLength(6)\n                .whenInvalid { println(\"Must contain min. 4, max 6 characters\") }\n                .build()\n        )\n        .addRule(\n            DefaultRuleBuilder\u003cCharSequence\u003e()\n                .isValid { it.contains(\"@\") || it.contains(\"!\") }\n                .whenInvalid { println(\"Must contain at least one of the @ or ! characters.\") }\n                .build()\n        )\n        .build()\n\n    pinCheckpoint.canPass(\"123\") // returns false and invokes whenInvalid()\n    pinCheckpoint.canPass(\"1234\") // returns false and invokes whenInvalid()\n    pinCheckpoint.canPass(\"1234@6!\") // returns false and invokes whenInvalid()\n    pinCheckpoint.canPass(\"1234@6\") // returns true\n}\n```\n\n### Base classes\n\nCheckpoint has several base classes which can be used for creating custom checkpoints and rules:\n\n  - [`com.natigbabayev.checkpoint.core.Rule`][rule]\n  - [`com.natigbabayev.checkpoint.core.DefaultRule`][default-rule]\n  \n\nCreating new rule:\n\n```kotlin\nclass NotEmpty(override val callback: Callback\u003cString\u003e) : DefaultRule\u003cString\u003e() {\n    override fun isValid(input: String): Boolean {\n        return input.isNotEmpty()\n    }\n}\n\nfun main() {\n    val rule = NotEmpty(\n        Rule.Callback { println(\"Cannot be empty\") }\n    )\n    \n    val checkpoint = Checkpoint.Builder()\n        .addRule(rule)\n        .build()\n}\n```\n\n## License\n\n```\nCopyright 2020 Natig Babayev\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n[snap]: https://oss.sonatype.org/content/repositories/snapshots/\n[rule]: https://www.natigbabayev.com/Checkpoint/javadoc/checkpoint-core-abstraction/com.natigbabayev.checkpoint.core/-rule/index.html\n[default-rule]: https://www.natigbabayev.com/Checkpoint/javadoc/checkpoint-core-abstraction/com.natigbabayev.checkpoint.core/-default-rule/index.html\n[checkpoint]: https://www.natigbabayev.com/Checkpoint/javadoc/checkpoint-core-abstraction/com.natigbabayev.checkpoint.core/-checkpoint/index.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatiginfo%2Fcheckpoint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatiginfo%2Fcheckpoint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatiginfo%2Fcheckpoint/lists"}