{"id":13485415,"url":"https://github.com/doov-org/doov","last_synced_at":"2025-03-27T19:31:05.934Z","repository":{"id":44058038,"uuid":"144585798","full_name":"doov-org/doov","owner":"doov-org","description":"dOOv (Domain Object Oriented Validation) a fluent API for type-safe bean validation and mapping","archived":false,"fork":false,"pushed_at":"2023-01-04T23:07:07.000Z","size":9806,"stargazers_count":93,"open_issues_count":14,"forks_count":16,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-05T13:01:45.763Z","etag":null,"topics":["dsl","fluent-api","java"],"latest_commit_sha":null,"homepage":"https://doov.org","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/doov-org.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":"2018-08-13T13:47:00.000Z","updated_at":"2025-03-02T05:11:19.000Z","dependencies_parsed_at":"2023-02-02T23:15:23.611Z","dependency_job_id":null,"html_url":"https://github.com/doov-org/doov","commit_stats":null,"previous_names":["doov-io/doov"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doov-org%2Fdoov","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doov-org%2Fdoov/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doov-org%2Fdoov/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doov-org%2Fdoov/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doov-org","download_url":"https://codeload.github.com/doov-org/doov/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910751,"owners_count":20692497,"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":["dsl","fluent-api","java"],"created_at":"2024-07-31T18:00:22.002Z","updated_at":"2025-03-27T19:31:05.044Z","avatar_url":"https://github.com/doov-org.png","language":"Java","funding_links":[],"categories":["Projects","项目","Bean映射\u0026复制"],"sub_categories":["Bean Mapping","Bean映射"],"readme":"# dOOv (Domain Object Oriented Validation)\n\n[![Build Status](https://travis-ci.org/doov-org/doov.svg?branch=master)](https://travis-ci.org/doov-org/doov)\n[![Build status](https://ci.appveyor.com/api/projects/status/xpesv3x6bwt00ucj/branch/master?svg=true)](https://ci.appveyor.com/project/ozangunalp/doov-j6ky3/branch/master)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.doov/doov-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.doov/doov-core)\n\ndOOv is a fluent API for typesafe domain model validation and mapping. It uses annotations, code generation and a type safe DSL to make domain model validation and mapping fast and easy.\n\n![dOOv logo](docs/svg/doov_logo_2020_blue.svg)\n\n## Documentation\n\nSee the [getting started](https://github.com/doov-org/doov/wiki/Getting-Started) section in the wiki, or see the small [usage overview](#usage).\n\n## Example\n\nSee the [the sample project in dOOv](sample). It contains two model domains, maven and gradle code generation, and example rules.\n\n## Conferences\n\nSee our [presentation slides](https://doov.org/conference/dsl_to_go_beyond_bean_validation_jdk_io.html) at JDK.IO.\n\nSee our [presentation slides](https://doov.org/conference/dsl_to_go_beyond_bean_validation_ocode.html) at Oracle Code One.\n\nSee our [presentation slides](https://doov.org/conference/implementing_failure_causes_with_doov.html) about the implementation of failure cause at Sorbonne University.\n\nSee our [presentation slides](https://doov.org/conference/how_to_create_dsl_with_lambda_builders_roma.html) latest update done at Oracle Code Rome.\n\n## Usage\n\n### Overview\n\nAnnotate your model with @Path annotations on field, qualifying them with field ids (see wiki section [Domain Model Annotation](https://github.com/doov-org/doov/wiki/Domain-Model-Annotation))\n\n```java\npublic class User {\n\n    @SamplePath(field = SampleFieldId.FIRST_NAME, readable = \"user first name\")\n    private String firstName;\n\n    @SamplePath(field = SampleFieldId.LAST_NAME, readable = \"user last name\")\n    private String lastName;\n\n    @SamplePath(field = SampleFieldId.BIRTHDATE, readable = \"user birthdate\")\n    private LocalDate birthDate;\n\n}\n```\n\nUse the dOOv code generator to generate a DSL with elements `userFirstName`, `userLastName` and `userBirthDate` (see wiki section [DSL Code Generation](https://github.com/doov-org/doov/wiki/DSL-Code-Generation)).\n\n### Validation\n\nThen write your rules with entry point `DOOV#when` and terminal operation `ValidationRule#validate` (see wiki section [Validation Rules](https://github.com/doov-org/doov/wiki/Validation-Rules)).\n\n```java\nValidationRule rule = DOOV.when(userBirthdate.ageAt(today()).greaterOrEquals(18))\n                          .validate();\n```\n\nYou can create more complex rules by chaining `and` and `or` or by using matching methods from the `DOOV` class like `matchAny`, etc.\n\n```java\nDOOV.when(userBirthdate.ageAt(today()).greaterOrEquals(18)\n     .and(userFullName.isNotNull()))\n    .validate()\n```\n\nYou can then execute the rule on an instantiated model (see wiki section [Validation Engine](https://github.com/doov-org/doov/wiki/Validation-Engine)).\n\n```java\n// Execute the DSL on the model\nDslModel model = new SampleModelWrapper(sampleModel);\nResult result = rule.executeOn(model);\nif (result.isFalse()) {\n  // do stuff on the model that didn't validate\n}\n```\n\nThe result will return true or false depending on the result of the predicate, for example `Result#isTrue` means the predicate validated.\n\n### Mapping\n\nUse `DOOV#map` to write mapping code using the DSL.\n\n```java\nMappingRegistry mappings = mappings(\n  map(userFirstName, userLastName)\n    .using(biConverter((first, last) -\u003e first + \" \" + last))\n    .to(accountFullName),\n  map(userBirthdate)\n    .using(date -\u003e Years.yearsBetween(date, LocalDate.now()))\n    .to(accountAge));\n```\n\nYou can then execute the mapping code on two instantiated models.\n\n```java\nDslModel model1 = new SampleModelWrapper(sampleModel1);\nDslModel model2 = new SampleModelWrapper(sampleModel2);\nContext context = mappings.executeOn(model1, model2);\n// do stuff with model2 new values\n```\n\n### Syntax tree\n\nThe rules provides an AST that can be printed as a human readable format with the `Readable#readable` method that is available on any DSL object. By default the output is from `AstLineVisitor` that outputs the string in plain text (see wiki section [Validation Engine](https://github.com/doov-org/doov/wiki/Validation-Engine)).\n\n```java\nDOOV.when(userBirthdate.ageAt(today()).greaterOrEquals(18)).validate().readable()\n\u003e When user age at 'today' greater or equals '18', validate with empty message\n```\n\n### Testing\n\nAssertions are available in the `doov-assertions` jar. It depends on AssertJ, so you can use the `assertThat` syntax (see wiki section [Testing Rules](https://github.com/doov-org/doov/wiki/Testing-Rules)).\n\n```java\nValidationRule rule = DOOV.when(userFirstName.isNotNull().or(userLastName.isNull())).validate();\nassertThat(rule).validates(model).hasFailedNodeEmpty();\n```\n\n## Build\n\nTo build core, assertions, generator core, maven generator plugin and gradle generator plugin modules:\n\n```bash\n# Core\n./gradlew build\n\n# Sample modules with examples\n./gradlew -p sample build\n```\n\nTo deploy you need to configure the command line options for your repository:\n\n```bash\n./gradlew \\\n  -Psigning.secretKeyRingFile=secret-file.gpg \\\n  -Psigning.keyId=key-id \\\n  -Psigning.password=password \\\n  -PsnapshotRepository=http://www.acme.com/repository/snapshots \\\n  -Prepository=http://www.acme.com/repository/releases \\\n  -PossrhUsername=userName \\\n  -PossrhPassword=password \\\n  deploy\n```\n\nYou can either specify `snapshotRepository` or `repository` depending on the version type.\n\nTo generate documentation with gradle:\n\n```bash\n# Generate documentation in docs/site/apidocs/subproject\n./gradlew javadoc\n```\n\n## Release\n\nTo release the code, it will create 2 commits with proper tags and versions and push them:\n\n```bash\n./gradlew \\\n  -Psigning.secretKeyRingFile=secret-file.gpg \\\n  -Psigning.keyId=key-id \\\n  -Psigning.password=password \\\n  -PsnapshotRepository=http://www.acme.com/repository/snapshots \\\n  -Prepository=http://www.acme.com/repository/releases \\\n  -PossrhUsername=userName \\\n  -PossrhPassword=password \\\n  -Pversions.newVersion=RELEASE_VERSION \\\n  release\n```\n\n## Licence\n\n[Apache-2.0](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoov-org%2Fdoov","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoov-org%2Fdoov","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoov-org%2Fdoov/lists"}