{"id":16619980,"url":"https://github.com/cepr0/sb-constraint-validator-injection-demo","last_synced_at":"2026-05-06T00:06:50.165Z","repository":{"id":130472470,"uuid":"328487516","full_name":"Cepr0/sb-constraint-validator-injection-demo","owner":"Cepr0","description":"Demo of the custom ConstraintValidator as a Spring Bean","archived":false,"fork":false,"pushed_at":"2021-01-10T21:57:19.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T11:51:49.382Z","etag":null,"topics":["bean","constraint-validation","injection","spring","spring-boot","validation"],"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/Cepr0.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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}},"created_at":"2021-01-10T21:57:02.000Z","updated_at":"2021-01-10T21:58:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"87777ca3-eebc-4737-b918-a4dd1ff6c284","html_url":"https://github.com/Cepr0/sb-constraint-validator-injection-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cepr0/sb-constraint-validator-injection-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fsb-constraint-validator-injection-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fsb-constraint-validator-injection-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fsb-constraint-validator-injection-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fsb-constraint-validator-injection-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cepr0","download_url":"https://codeload.github.com/Cepr0/sb-constraint-validator-injection-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cepr0%2Fsb-constraint-validator-injection-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32672688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bean","constraint-validation","injection","spring","spring-boot","validation"],"created_at":"2024-10-12T02:43:13.142Z","updated_at":"2026-05-06T00:06:50.150Z","avatar_url":"https://github.com/Cepr0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Demo of the custom ConstraintValidator as a Spring Bean\n\nSpring Boot allows injecting Spring beans to a ConstraintValidator, for example:\n\n```java\n@Slf4j\npublic class CaseValidator implements ConstraintValidator\u003cCheckCase, String\u003e {\n\n    private final Predicate\u003cString\u003e uppercasePredicate;\n    private final Predicate\u003cString\u003e lowercasePredicate;\n\n    private CheckCase.CaseMode caseMode;\n\n    @Autowired // not necessary annotation\n    public CaseValidator(Predicate\u003cString\u003e uppercasePredicate, Predicate\u003cString\u003e lowercasePredicate) {\n        this.uppercasePredicate = uppercasePredicate;\n        this.lowercasePredicate = lowercasePredicate;\n    }\n\n    @Override\n    public void initialize(CheckCase constraintAnnotation) {\n        this.caseMode = constraintAnnotation.value();\n    }\n\n    @Override\n    public boolean isValid(String value, ConstraintValidatorContext context) {\n        if (value == null) return true;\n\n        if (caseMode == CheckCase.CaseMode.UPPER) {\n            log.info(\"[i] Checking uppercase for value: {}\", value);\n            return uppercasePredicate.test(value);\n        } else {\n            log.info(\"[i] Checking lowercase for value: {}\", value);\n            return lowercasePredicate.test(value);\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fsb-constraint-validator-injection-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcepr0%2Fsb-constraint-validator-injection-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcepr0%2Fsb-constraint-validator-injection-demo/lists"}