{"id":16261216,"url":"https://github.com/fuxingloh/hibernate-validator-enum","last_synced_at":"2026-05-02T06:38:17.317Z","repository":{"id":57731149,"uuid":"256308796","full_name":"fuxingloh/hibernate-validator-enum","owner":"fuxingloh","description":"So, null \u0026 unknown value handling for enum has always been an issue for me, saw the implementation on Amazon Java SDK packages and created @ValidEnum constraints to support using Hibernate Validator library.","archived":false,"fork":false,"pushed_at":"2020-05-31T05:56:09.000Z","size":72,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T00:49:50.932Z","etag":null,"topics":["bean","enum","enums","hibernate-validator","java","json","validation","validator"],"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/fuxingloh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-16T19:21:33.000Z","updated_at":"2021-01-01T11:17:39.000Z","dependencies_parsed_at":"2022-09-26T22:01:48.448Z","dependency_job_id":null,"html_url":"https://github.com/fuxingloh/hibernate-validator-enum","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxingloh%2Fhibernate-validator-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxingloh%2Fhibernate-validator-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxingloh%2Fhibernate-validator-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxingloh%2Fhibernate-validator-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuxingloh","download_url":"https://codeload.github.com/fuxingloh/hibernate-validator-enum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856545,"owners_count":21007621,"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":["bean","enum","enums","hibernate-validator","java","json","validation","validator"],"created_at":"2024-10-10T16:40:49.616Z","updated_at":"2026-05-02T06:38:12.297Z","avatar_url":"https://github.com/fuxingloh.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hibernate Validator Enum\n\nSo, `null` \u0026 unknown value handling for enum has always been an issue for me when converting from JSON to Java.\n\nI saw an implementation on Amazon Java SDK packages. \nReally liked the design, I expanded on it to support JSON using the Jackson packages. \nI have also created @ValidEnum constraints to support using Hibernate Validator library.\n\n## This project consist of\n* IntelliJ Live Template\n* ValidEnum annotation \n* JSON, Jackson support\n* Enum `null`, `unknown value` handling.\n\n## Examples\n\n### Creating the enum with live template\n\u003e Using the live template to create enum, my keyword is: `UNKNOWN_TO_SDK_VERSION`\n```java\npublic enum Status {\n    ALLOWED(\"ALLOWED\"),\n    UNKNOWN_TO_SDK_VERSION(null);\n\n    private final String value;\n\n    Status(String value) {\n        this.value = value;\n    }\n\n    @Override\n    @JsonValue\n    public String toString() {\n        return String.valueOf(value);\n    }\n\n    /**\n     * Use this in place of valueOf to convert the raw string returned by the service into the enum value.\n     *\n     * @param value real value\n     * @return Status corresponding to the value\n     */\n    @JsonCreator\n    public static Status fromValue(String value) {\n        if (value == null) {\n            return null;\n        }\n        return Stream.of(Status.values()).filter(e -\u003e e.toString().equals(value)).findFirst()\n                .orElse(UNKNOWN_TO_SDK_VERSION);\n    }\n\n    public static Set\u003cStatus\u003e knownValues() {\n        return Stream.of(values()).filter(v -\u003e v != UNKNOWN_TO_SDK_VERSION).collect(Collectors.toSet());\n    }\n}\n```\n\n### Adding bean validation\n```java\npublic class Bean {\n    @ValidEnum\n    public Status status;\n}\n```\n\n## Download\n### Maven\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003edev.fuxing\u003c/groupId\u003e\n  \u003cartifactId\u003ehibernate-validator-enum\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n```groovy\ncompile group: 'dev.fuxing', name: 'hibernate-validator-enum', version: '1.0.0'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuxingloh%2Fhibernate-validator-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuxingloh%2Fhibernate-validator-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuxingloh%2Fhibernate-validator-enum/lists"}