{"id":13698770,"url":"https://github.com/hhelibeb/abap-data-validator","last_synced_at":"2025-09-06T18:46:47.102Z","repository":{"id":173610178,"uuid":"231032601","full_name":"hhelibeb/abap-data-validator","owner":"hhelibeb","description":"A data validation tool.","archived":false,"fork":false,"pushed_at":"2023-06-08T10:42:06.000Z","size":208,"stargazers_count":39,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T21:51:45.944Z","etag":null,"topics":["abap","datavalidation","sap"],"latest_commit_sha":null,"homepage":null,"language":"ABAP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hhelibeb.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}},"created_at":"2019-12-31T05:39:47.000Z","updated_at":"2024-12-30T22:35:36.000Z","dependencies_parsed_at":"2023-07-05T03:48:12.663Z","dependency_job_id":null,"html_url":"https://github.com/hhelibeb/abap-data-validator","commit_stats":null,"previous_names":["hhelibeb/abap-data-validator"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hhelibeb/abap-data-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhelibeb%2Fabap-data-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhelibeb%2Fabap-data-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhelibeb%2Fabap-data-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhelibeb%2Fabap-data-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hhelibeb","download_url":"https://codeload.github.com/hhelibeb/abap-data-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hhelibeb%2Fabap-data-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273948299,"owners_count":25196394,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"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":["abap","datavalidation","sap"],"created_at":"2024-08-02T19:00:52.717Z","updated_at":"2025-09-06T18:46:47.048Z","avatar_url":"https://github.com/hhelibeb.png","language":"ABAP","funding_links":[],"categories":["Categories"],"sub_categories":["🪄 Data Processing"],"readme":"# abap-data-validator\nA data validation tool.\n\nABAP Data Validator is a tool to simplify data validation process for SAP ABAP development.\n\nGoals:\n* General validation interface, which allows complete validation work by one method call.\n* Centralize some validation logic, avoid duplicate \u0026 inconsistent, decrease maintenance cost.\n* Avoid potential dump.\n\nTo achieve the goal, ABAP Data Validator has some features\n* Built-in validation logic.\n* Customizable validation rules.\n* Extendable validation program.\n* Internal exception handling.\n\n## Type list\nABAP Data Validator supports validations for types below (updating),\n- [x] Date.\n- [x] Time.\n- [x] Timestamp.\n- [x] Email.\n- [x] INT4.\n- [x] REGEX string.\n- [x] URL.\n- [x] JSON.\n- [x] HEX.\n- [x] IMEI.\n- [x] GUID.\n- [x] BASE64.\n- [x] HTML (experimental).\nAnd validation of mandatory, validate by reference data elements are also supported.\n\n## Usage\n\n### Single field validation \nFor every type, ABAP Data Validator has a special check class. You can use static method `is_valid` of check class to validate data just like a built-in function. Example:\n```abap\nIF zcl_adv_email_check=\u003eis_valid( 'example@github.com' ).\n \"do something\nENDIF.\n```\nEvery check class implements the interface `zif_adv_check`, which contains method`is_valid`.\n![check classere](https://raw.githubusercontent.com/hhelibeb/abap-data-validator/master/doc/img/uml1.png)\n\nThe naming convention of check classes is ZCL_ADV_typename_CHECK.\n\nAll classes have unit tests.\n\n### Validation with reference data element\nFor easy to use, `is_valid` is a quite simple method, that means it can't provide function on validation of quantity and amount type. In order to solve this issue, ABAP Data Validator provide another way to validate data.\n```abap\nDATA(result) = NEW zcl_adata_validator( )-\u003e-\u003evalidate_by_element(\n   data    = '11.0'\n   element = 'MENGE_D' \"quantity data element name\n).\n```\nNow data elements with below type are supported,\n- [x] Date.\n- [x] Time.\n- [x] Timestamp.\n- [x] INT4.\n- [x] GUID.\n- [x] HEX.\n- [x] Packed(including most of the quantity type and amount type).\n\nTo keep the check method simple, there is also no exception definition of the method `validate_by_element`. The method handles exceptions internally, and return a result with the result-valid = abap_false, result-type = 'Invalid Type' (fixed value).\n\n### Internal table validation\nClass `zcl_adata_validator` provides a general validation method `validate`. \n```abap\nTRY.\n    DATA(result) = NEW zcl_adata_validator( )-\u003evalidate(\n         rules   = my_rules\n         data    = uploaded_data\n     ).\n  CATCH zcx_adv_exception INTO DATA(ex).\n    DATA(msg) = ex-\u003eget_text( ).\nENDTRY.    \n```\n`zcl_adata_validator` calls check methods internally according to the exporting rules and returns the result.\n\n### Rules customization\nBy the parameter RULES, you can customize the validation.\n```abap\nDATA: rules TYPE zcl_adata_validator=\u003ety_rules_t.\n\nrules = VALUE #(\n  ( fname = 'FIELD1' required = abap_true  initial_or_empty = abap_false  user_type = zcl_adata_validator=\u003ec_type_date )\n  ( fname = 'FIELD2' required = abap_false initial_or_empty = abap_true   user_type = zcl_adata_validator=\u003ec_type_date )\n  ( fname = 'FIELD3' required = abap_true  initial_or_empty = abap_false  user_type = zcl_adata_validator=\u003ec_type_email )\n).\n```\n### Extend validation for special type\nThere are two ways to extend the validation:\n* Pass regular expression by RULES-REGEX.\n* Create a new class which implements `zif_adv_check`, and pass the type name \u0026 class name to `zcl_adata_validator-\u003econstructor`.\n\nRegex example. If you want to check whether the input email is a gmail address, you can assign `gmail\\.com$` to `rule-regex`:\n\n```abap\nDATA: rules TYPE zcl_adata_validator=\u003ety_rules_t.\n\nDATA: cases TYPE ty_case_t.\n\ncases = VALUE #(\n    ( field3 = 'ZZZ2@gmail.com') \"correct, it is a gmail address\n    ( field3 = 'ZZZ2@outlook.com') \"incorrect, it is not a gmail address\n).\n\nrules = VALUE #(\n  ( fname = 'FIELD3' user_type = zcl_adata_validator=\u003ec_type_email regex = 'gmail\\.com$' regex_msg = 'Only gmail supported')\n).\n```\nOr add a new class, and add it to check config on demand: \n```abap\nDATA: check_class_config TYPE zcl_adata_validator=\u003ety_check_config_t.\n\ncheck_class_config = VALUE #( ( type = zcl_adata_validator=\u003ec_type_new  class = 'ZCL_NEW_VALIDATOR' ) ).\n\nTRY.\n     DATA(result) = NEW zcl_adata_validator( check_class_conifg = check_class_config )-\u003evalidate(\n         rules   = rules\n         data    = cases\n     ).\nCATCH zcx_adv_exception INTO DATA(ex).\n    DATA(msg) = ex-\u003eget_text( ).\nENDTRY.\n ```\n### Configuration \nThe configuration is hard coded in `zcl_adata_validator`'s constructor. You can also pass you own configuration into the constructor. It allows you to change the function without modifying the existed program.\n\n```abap\nDATA: check_class_config TYPE zcl_adata_validator=\u003ety_check_config_t.\n\nSELECT * FROM my_config_table INTO TABLE @check_class_config.\n\nTRY.\n    DATA(result) = NEW zcl_adata_validator( check_class_conifg = check_class_config )-\u003evalidate(\n        rules   = rules\n        data    = cases\n    ).\nCATCH zcx_adv_exception INTO DATA(ex).\n    DATA(msg) = ex-\u003eget_text( ).\nENDTRY.\n\n```\nNote: Custom config will cover default config.\n\n## Requirment\nABAP Version: 740 SP08 or higher\n\nFor ABAP Cloud, there is another release which was contributed by [ArneVanH](https://github.com/ArneVanH). Please find it on the [Releases page](https://github.com/hhelibeb/abap-data-validator/releases). Refer to issue https://github.com/hhelibeb/abap-data-validator/issues/21 for more details\n\n## Exception\nThe exception class `zcx_adv_exception` is copied from `zcx_abapgit_exception` for it is easy to use:)\n\n## TODO\nNow only date, time and email type are supported. Need to add more check classes.\n- [ ] More types.\n- [ ] Auto Type detecting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhelibeb%2Fabap-data-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhhelibeb%2Fabap-data-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhhelibeb%2Fabap-data-validator/lists"}