{"id":19500594,"url":"https://github.com/naturalintelligence/detailed-xml-validator","last_synced_at":"2025-04-25T23:30:29.959Z","repository":{"id":38473035,"uuid":"410730487","full_name":"NaturalIntelligence/detailed-xml-validator","owner":"NaturalIntelligence","description":"Validate for XML schema and returns all the possible failures","archived":false,"fork":false,"pushed_at":"2023-04-09T10:01:51.000Z","size":56,"stargazers_count":17,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-23T13:41:42.042Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/NaturalIntelligence.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}},"created_at":"2021-09-27T03:33:10.000Z","updated_at":"2025-03-22T13:57:03.000Z","dependencies_parsed_at":"2024-01-23T21:35:19.584Z","dependency_job_id":null,"html_url":"https://github.com/NaturalIntelligence/detailed-xml-validator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Fdetailed-xml-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Fdetailed-xml-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Fdetailed-xml-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Fdetailed-xml-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaturalIntelligence","download_url":"https://codeload.github.com/NaturalIntelligence/detailed-xml-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250912660,"owners_count":21506865,"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":[],"created_at":"2024-11-10T22:09:04.050Z","updated_at":"2025-04-25T23:30:29.731Z","avatar_url":"https://github.com/NaturalIntelligence.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# detailed-xml-validator\nValidate for XML schema and returns all the possible failures\n\nThis module uses it's own rule file which is different than XSD and looks more like XML data file. More features would be added in future versions. Currently, it just ensures frequency, type, range, value length, value pattern and null validations only on top of syntax check done by FXP.\n\nIf there is no syntax error, then this module reports all failures and don't exit on first faliure. So you can report all the issues in one go.\n\nSample Rules file\n```xml\n\u003c?xml version = \"1.0\"?\u003e\n\n\u003cstudents nillable=\"false\"\u003e\n    \u003cstudent repeatable minOccurs=\"1\"\u003e\n        \u003c:a\u003e\n            \u003cid length=\"6\"\u003e\u003c/id\u003e\n        \u003c/:a\u003e\n        \u003cfirstname minLength=\"3\" maxLength=\"10\" nillable=\"false\"\u003e\u003c/firstname\u003e\n        \u003clastname minLength=\"3\" maxLength=\"10\" nillable=\"false\"\u003e\u003c/lastname\u003e\n        \u003cnickname minLength=\"3\" maxLength=\"10\"\u003e\u003c/nickname\u003e\n        \u003cemail pattern=\"[a-z0-9]+@schoolname.org\" nillable=\"false\"\u003e\u003c/email\u003e\n        \u003cage type=\"positiveInteger\" min=\"9\" max=\"19\"\u003e\u003c/age\u003e\n        \u003ccontact\u003e\n            \u003cphone length=\"10\"\u003e\u003c/phone\u003e\n        \u003c/contact\u003e\n        \u003cgender nillable=\"false\" \u003e\u003c/gender\u003e\n        \u003cmarks\u003e\n            \u003csubject repeatable minOccurs=\"5\" maxOccurs=\"6\" checkBy=\"subjectValidator\"\u003e\n                \u003cname pattern=\"math|hindi|english|science|history\"\u003e\u003c/name\u003e\n                \u003c!-- \u003cname in=\"math,hindi,english,science,history\"\u003e\u003c/name\u003e --\u003e\n                \u003cscore type=\"positiveDecimal\"\u003e\u003c/score\u003e\n            \u003c/subject\u003e\n        \u003c/marks\u003e\n\n    \u003c/student\u003e\n\u003c/students\u003e\n```\n\n* **:a**: This is the special tag used to define rules for attributes\n* **nillable**: By default all the elements are nillable. Set it to `false` to mark an element mandatory. For lists, if `minOccurs` is set to `1`, it means it can't be nillable.\n* **repeatable**: A list must have this attribute\n    * **minOccurs**: To validate minimum number of elements in a list\n    * **maxOccurs**: To validate maximum number of elements in a list\n* **type**: You can define type to put the restriction on their values. Eg `positiveInteger` can't have negative values. Following types are supported\n    * **positiveInteger** : \n    * **positiveDecimal** : \n    * **integer** : \n    * **decimal** : \n    * **number** : \n    * **date** : \n    * **string** : default type (optional)\n    * **map** : object type (optional)\n* **Number type**: Following validations can be applied on number type\n    * **min**:\n    * **max**:\n* **String type**: Following validations can be applied on string type\n    * **minLength**:\n    * **maxLength**:\n    * **length**:\n    * **in**: comma separated string for exact match (from v1.0.0)\n    * **fixed**: exact match (from v1.0.0)\n    * **pattern**: regex match\n    * **pattern_i**: regex (case insensitive)\n    * **pattern_m**: regex (multiline)\n    * **pattern_im**: regex (case insencitive and multiline)\n* **checkBy**: (from v1.0.0) Give the name of validator that you registered with validator. This validator will be called with an object of nested tags (or value if it is a leaf node) and path.\n\n\nSample code \n```js\nconst Validator = require(\"detailed-xml-validator\");\n\nconst options = {\n    unknownAllow: true,\n    boolean: [\"true\", \"false\"],\n};\n\nconst validator = new Validator(rules, options);\n\nvalidator.register(\"subjectValidator\", (obj, path) =\u003e { //From v1.0.0\n    //return; //if no error\n    //return {} //return an error msg object\n})\nconst failures = validator.validate(xmlStringData);\nconst originalXmlJsObj = validator.data;\nconsole.log(`Found ${failures.length} issues`);\n```\n\nSample Response\n```js\n[\n    { code: 'missing', path: 'root.d'} ,\n    { code: 'unknown', path: 'root.f'} \n    { code: 'minLength', path: 'root.a[0]', actual: '0', expected: 15 },\n    {\n        code: 'pattern',\n        path: 'root.a[0]',\n        actual: '0',\n        expected: '[a-z]+@gmail.com'\n    },\n    { code: 'not a boolean', path: 'root.a[0]', value: 'yes' },\n    { code: 'not a integer', path: 'root.f[2]', value: 'acbc' },\n    { code: 'max', path: 'root.d', actual: 3.2, expected: 1.5 },\n    { code: 'unexpected value in a map', path: 'root.b[1]', value: 'amit' }\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalintelligence%2Fdetailed-xml-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaturalintelligence%2Fdetailed-xml-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalintelligence%2Fdetailed-xml-validator/lists"}