{"id":18586693,"url":"https://github.com/meks77/easy-validation","last_synced_at":"2025-06-26T08:03:51.893Z","repository":{"id":57714972,"uuid":"130158530","full_name":"meks77/easy-validation","owner":"meks77","description":"Very easy way to validate simple and complex objects by using a fluent interface","archived":false,"fork":false,"pushed_at":"2023-10-25T15:18:26.000Z","size":428,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T18:54:33.792Z","etag":null,"topics":["fluent-api","java","validation"],"latest_commit_sha":null,"homepage":"","language":"Java","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/meks77.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-19T04:22:28.000Z","updated_at":"2024-12-09T19:53:57.000Z","dependencies_parsed_at":"2022-09-02T22:01:14.394Z","dependency_job_id":"be55da6e-582a-4e15-ad4a-321354573d10","html_url":"https://github.com/meks77/easy-validation","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/meks77/easy-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meks77%2Feasy-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meks77%2Feasy-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meks77%2Feasy-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meks77%2Feasy-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meks77","download_url":"https://codeload.github.com/meks77/easy-validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meks77%2Feasy-validation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262026903,"owners_count":23246952,"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":["fluent-api","java","validation"],"created_at":"2024-11-07T00:38:19.936Z","updated_at":"2025-06-26T08:03:51.869Z","avatar_url":"https://github.com/meks77.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=sqale_index)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=at.meks%3Aeasy-validation-parent\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=at.meks%3Aeasy-validation-parent)\n# easy-validation \n\nVery easy way to validate simple and complex objects by using an fluent interface.\n\n## Goals\n\n * No 3rd party dependencies\n * Very small artefact size\n * clean and natural api\n\n## Examples\n\n### Simply validate a method argument and throw an IllegalArgumentException\n\nIf you want to validate just a method argument you can do this by using the module easy-validation-args.\n\n````\nvalidate().that(arg1)\n        .withMessage(() -\u003e \"arg1\")\n        .isNotBlank()\n        .hasMinLength(30)\n        .matches(value -\u003e value.contains(\"whatIsExpected\"));\n````\n\nCommonly when you implement a validation the code would look like this:\n\n````\nif (StringUtils.isBlank(arg1)) {\n    throw new IllegalArgumentException(\"arg1\");\n}\nif (arg1.length() \u003c= 30) {\n    throw new IllegalArgumentException(\"arg1\");\n}\nif (arg1.contains(\"whatIsExpected\") {\n    throw new IllegalArgumentException(\"arg1);\n}\n````\nJust imagine you have 20+ different input values you have to validate. The code is growing very fast and it will get hard\nto maintain as it grows.\n\nYou also have the possibility to set a seperate message per validation.\n````\nvalidate().that(arg1)\n        .withMessage(() -\u003e \"arg1 mustn't be blank\").isNotBlank()\n        .withMessage(() -\u003e \"arg1 must have at leat 30 chars\").hasMinLength(30)\n        .withMessage(() -\u003e \"arg1 must contain \\\"whatIsExpected\\\"\").matches(value -\u003e value.contains(\"whatIsExpected\"));\n````\n\n### Do more validations to report in any way you want\n\nExpect the case you want to validate the input to be not blank and it mustn't contain whitespace, but you want to report\nit with different error messages.\n\n````\nList\u003cString\u003e occuredErrorKeys = new ArrayList\u003c\u003e();\nString validatedValue = \" \";\nValidator.reportTo(occuredErrorKeys::add)\n        .verify(validatedValue)\n        .usingKey(\"notBlank\").matches(StringUtils::isNotBlank)\n        .and().usingKey(\"whitespaces\").matches(StringUtils::doesNotContainWhitespace)\n        .and().usingKey(\"minLength\").matches(value -\u003e StringUtils.length(value) \u003e 10);\n````\nIn the list occuredErrorKeys the errors notBlank, whitespaces and minLength will be added. With this information you can report\nthe error however you want.\n\n### Throw the Exception you want\nIf you have the need to throw your own exception in case of the first violation, e.g. for throwing an error code, just\ngo ahead like this:\n````\nValidator.stopOnFirstError()\n        .throwing(() -\u003e new MyCheckedExceptionWithErrorCode(999))\n        .verify(validatedValue)\n        .matches(StringUtils::isNotBlank)\n        .and(StringUtils::doesNotContainWhitespace)\n````\n\n## Matchers\nFirst I thought using commons-lang3 is fine. But I realized that commons-lang3 size is about 500 KB.\nFurthermore: How to avoid dependency clashes?\n\nTherefore I decided to use my own matchers. Currently in version 2.0.0-RC2 the size is ~ 6 KB. \nFurthermore the whole validation has no dependency to any 3rd party library. So you can use always as long you use at least\njava 11.  \n\n## Details and Maven Coordinates\nMore Details and Maven Coordinates can be found at the modules:\n\n* [Matchers](matcher/Readme.md)\n* [Core](core/Readme.md)\n* [Args](args/Readme.md)\n\n## History \nWhile developing the first release I followed the main concept of using lambda combined with a fluent interface is from Joel Planes, what can be found [here](https://medium.com/@jplanes/lambda-validations-with-java-8-86aa8143bd9f).\n\nBut I was getting tired to always invoke the method test and afterwards the method throwIfInvalid.\n\nThanks to Eric Evans input I developed it from scratch with the possibility to decide if I want to throw an exception or not easy, without duplicating so much method signatures.\nI hope you like the result.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeks77%2Feasy-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeks77%2Feasy-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeks77%2Feasy-validation/lists"}