{"id":24483947,"url":"https://github.com/manuelarte/spring-utils","last_synced_at":"2026-04-27T08:31:54.880Z","repository":{"id":273000256,"uuid":"918260230","full_name":"manuelarte/spring-utils","owner":"manuelarte","description":"🛠️ Spring Boot utilities java library. Contains a series of utilities to be used with Spring Boot v3","archived":false,"fork":false,"pushed_at":"2026-03-31T07:08:55.000Z","size":227,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-31T09:29:06.792Z","etag":null,"topics":["library","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manuelarte.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-17T15:13:52.000Z","updated_at":"2026-03-31T07:08:56.000Z","dependencies_parsed_at":"2025-03-03T16:24:25.321Z","dependency_job_id":"91ccc870-0b43-474d-bdba-0233ddddc158","html_url":"https://github.com/manuelarte/spring-utils","commit_stats":null,"previous_names":["manuelarte/spring-utils"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/manuelarte/spring-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelarte%2Fspring-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelarte%2Fspring-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelarte%2Fspring-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelarte%2Fspring-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manuelarte","download_url":"https://codeload.github.com/manuelarte/spring-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manuelarte%2Fspring-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32329463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"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":["library","spring-boot"],"created_at":"2025-01-21T13:13:10.257Z","updated_at":"2026-04-27T08:31:54.806Z","avatar_url":"https://github.com/manuelarte.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠️ Spring-Utils library\n\n## ⬇️ Installation\n\nAdd the following dependency in your project to start using the features described below.\n\n\u003cdetails\u003e\n\u003csummary\u003eGradle Kotlin\u003c/summary\u003e\n\n```\nimplementation(\"com.github.manuelarte.spring-utils:{latest-version}\")\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGradle Groovy\u003c/summary\u003e\n\n```\nimplementation 'com.github.manuelarte.spring-utils:{latest-version}'\n```\n\u003c/details\u003e\n\n## 🤓 Overview\n\nSome helpful validations and utilities to be used in your [Spring Boot](https://spring.io/projects/spring-boot) application. \n\nCheck the features list below.\n\n## 📋 Features\n\nBelow you can find a description on the available features in this library, in case you want to see them in a real project check the [Example Project](#example-project) section.\n\n### CrupRepository\n\nExtension for the [Spring Data Repository](https://docs.spring.io/spring-data/jpa/reference/index.html) to allow **partial updates**.\n\n#### Prerequisites\n\n- The entity needs to have a single field with `@Id` attribute\n\n#### Example\n\n```java\n@Entity\npublic class DocumentEntity {\n    @Id\n    private final Long id;\n    private final String name;\n    private final String surname;\n    ...\n}\n\n@Repository\npublic interface DocumentEntityRepository extends CrpudRepository\u003cDocumentEntity, Long\u003e {}\n\nfinal DocumentEntity saved = repository.save(new DocumentEntity(1, \"Manuel\", \"D\"));\nfinal DocumentEntity partialUpdate = new DocumentEntity(null, null, \"Doncel\");\nfinal DocumentEntity partialUpdated = repository.partialUpdate(1, partialUpdate);\n// Result id:1, name: Manuel, surname: Doncel\n```\n\n### @Exists Constraint\n\nThe `@Exists` constraint can be used to **check if the entity exists before executing the method**. It checks whether the repository contains an entity with the specified id.\nThis allows you to abstract the validation logic from the business logic.\n\n#### Prerequisites\n\n- The constraint validations need to be executed, for example annotating your Controller with `@Validated`.\n- The entity/document that is going to be checked needs to have a `@Repository` bean.\n- The following dependency is needed: `implementation(\"org.springframework.boot:spring-boot-starter-validation\")`\n\n#### Example\n\nHere there is an example of a controller that gets a Document by id. The @Exists constrains check whether the id exists before executing the method.\n\n```java\n@Validated\npublic class DocumentController {\n    @GetMapping(value = \"/{id}\", produces = MediaType.APPLICATION_JSON_VALUE)\n    public ResponseEntity\u003cDocumentEntity\u003e findOne(\n    @PathVariable @Exists(DocumentEntity.class) final String id) {\n        return ResponseEntity.ok(documentService.findOne(id));\n    }\n}\n\n@Repository\npublic interface DocumentEntityRepository extends CrudRepository\u003cDocumentEntity, Long\u003e {}\n```\n\n### @New, @PartialUpdate, @Update Validation Groups\n\nHelper annotations to be used in your DTOs to be used\nas [validation groups](https://jakarta.ee/specifications/bean-validation/).\n\n#### Example\n\nImagine that you have an entity that you want to allow to be `created`, `updated` and `partially updated`.\nBy using validation groups, we can have the same DTO for the different CRUD endpoints. Here is an example:\n\n```java\npublic class OneEntityDto {\n\n    @Null(groups = {New.class, PartialUpdate.class})\n    @NotNull(groups = Update.class)\n    // id is mandatory for the @New and @Update validation group, but not for @PartialUpdate \n    private final Long id;\n\n    @NotEmpty(groups = {New.class, Update.class})\n    // firstName can't be empty for @New and @Update, but can be empty for @PartialUpdate\n    private final String firstName;\n    @NotEmpty(groups = {New.class, Update.class})\n    // lastName can't be empty for @New and @Update, but can be empty for @PartialUpdate\n    private final String lastName;\n\n}\n\n@RestController\n@Validated\npublic class OneEntityController {\n    @PostMapping(value = \"/\", produces = MediaType.APPLICATION_JSON_VALUE)\n    public ResponseEntity\u003cOneEntity\u003e saveOne(\n            @Validated({Default.class, New.class}) @RequestBody final OneEntity saveEntity) {\n        // saveEntity will be validated with the @New validation group\n    }\n    \n    @PostMapping(value = \"/{id}\", produces = MediaType.APPLICATION_JSON_VALUE)\n    public ResponseEntity\u003cOneEntity\u003e updateOne(\n        @Validated({Default.class, Update.class}) @RequestBody final OneEntity updateEntity) {\n        // updateEntity will be validated with the @Update validation group\n    }\n\n    @PatchMapping(value = \"/{id}\", produces = MediaType.APPLICATION_JSON_VALUE)\n    public ResponseEntity\u003cOneEntity\u003e partialUpdateOne(\n            @Validated({Default.class, PartialUpdate.class}) @RequestBody final OneEntity patchEntity) {\n        // patchEntity will be validated with the @PartialUpdate validation group\n    }\n}\n```\n\n### FromAndToDate Constraint\n\n`@FromAndToDate` constraint helps to validate two dates.\n\n#### Class Level Example\n\n```java\n@FromAndToDate\npublic class EntityExample {\n    @FromDate\n    private final Date from;\n    @ToDate\n    private final Date to;\n    ...\n}\n```\n\nThe constraint will check that the field from is lower than to the to parameter\n\n#### Method Level Example\n\n```java\n@FromAndToDate\npublic void methodExample(final Date from, final Date to) {\n    //...\n}\n```\n\nThe constraint will check that the parameters from and to match from is before than to.\nBy default, the constraint will check the 1st and 2nd parameters indexes. In case they are in a different index it should be set like this:\n\n```java\n@FromAndToDate(paramIndexes={x,y})\n```\n\nwhere `x` and `y` are the indexes of the parameters to be checked.\n\n## Example Project\n\nIn the [_example](_example) folder there is a Spring Boot project showing the features available in this library.\n\n## 🤝 Contributing\nFeel free to create a PR or suggest improvements or ideas.\n\n## Publish\n\nTo publish a new version use:\n\n\u003e ./gradlew publish\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanuelarte%2Fspring-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanuelarte%2Fspring-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanuelarte%2Fspring-utils/lists"}