{"id":20964550,"url":"https://github.com/hyparam/csv-validator","last_synced_at":"2025-07-12T04:41:28.805Z","repository":{"id":220445371,"uuid":"750483407","full_name":"hyparam/csv-validator","owner":"hyparam","description":"CSV validator for Guardrails AI","archived":false,"fork":false,"pushed_at":"2024-05-27T19:35:57.000Z","size":128,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-14T09:43:19.388Z","etag":null,"topics":["ai","csv","guardrails"],"latest_commit_sha":null,"homepage":"","language":"Python","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/hyparam.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,"publiccode":null,"codemeta":null}},"created_at":"2024-01-30T18:20:52.000Z","updated_at":"2024-05-27T19:36:01.000Z","dependencies_parsed_at":"2024-11-19T07:02:11.685Z","dependency_job_id":null,"html_url":"https://github.com/hyparam/csv-validator","commit_stats":null,"previous_names":["hyparam/csv-validator"],"tags_count":0,"template":false,"template_full_name":"guardrails-ai/validator-template","purl":"pkg:github/hyparam/csv-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyparam%2Fcsv-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyparam%2Fcsv-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyparam%2Fcsv-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyparam%2Fcsv-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyparam","download_url":"https://codeload.github.com/hyparam/csv-validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyparam%2Fcsv-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260897786,"owners_count":23079224,"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":["ai","csv","guardrails"],"created_at":"2024-11-19T02:56:01.932Z","updated_at":"2025-06-20T06:38:12.261Z","avatar_url":"https://github.com/hyparam.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guardrails CSV Validator\n\n![csv-validator](csv-validator.jpg)\n\n[![apache license](https://img.shields.io/badge/License-Apache2-blue.svg)](https://opensource.org/licenses/Apache-2-0)\n\n|||\n|---| --- |\n| Developed by | Hyperparam |\n| Date of development | Feb 15, 2024 |\n| Validator type | Format |\n| Blog |  |\n| License | Apache 2 |\n| Input/Output | Output |\n\n## Description\n\n### Intended Use\n\nA CSV validator for [Guardrails AI](https://www.guardrailsai.com/).\n\nThis validator checks for various CSV issues such as mismatched column lengths, or mismatched quote delimiters.\n\n### Requirements\n\n* Dependencies:\n\t- guardrails-ai\u003e=0.4.0\n\n## Installation\n\n```bash\n$ guardrails hub install hub://hyparam/csv_validator\n```\n\n## Usage Examples\n\n### Validating string output via Python\n\nIn this example, we apply the validator to a string output generated by an LLM.\n\n```python\n# Import Guard and Validator\nfrom guardrails.hub import CsvMatch\nfrom guardrails import Guard\n\n# Setup Guard\nguard = Guard().use(\n    CsvMatch\n)\n\nguard.validate(\"name,email\\njohn,john@example.com\\njane,jane@example.com\")  # Validator passes\nguard.validate(\"name,email\\njohn\\njane,jane@example.com\")  # Validator fails\n```\n\n### Validating JSON output via Python\n\nIn this example, we apply the validator to a string field of a JSON output generated by an LLM.\n\n```python\n# Import Guard and Validator\nfrom pydantic import BaseModel, Field\nfrom guardrails.hub import CsvMatch\nfrom guardrails import Guard\n\n# Initialize Validator\nval = CsvMatch()\n\n# Create Pydantic BaseModel\nclass DbBackup(BaseModel):\n\t\tdb_name: str\n\t\tdata: str = Field(validators=[val])\n\n# Create a Guard to check for valid Pydantic output\nguard = Guard.from_pydantic(output_class=DbBackup)\n\n# Run LLM output generating JSON through guard\nguard.parse(\"\"\"\n{\n    \"db_name\": \"USERS\",\n    \"data\": \"name,email\\njohn,john@example.com\\njane,jane@example.com\"\n}\n\"\"\")\n```\n\n# API Reference\n\n**`__init__(self, on_fail=\"noop\")`**\n\u003cul\u003e\nInitializes a new instance of the CsvMatch class.\n\n**Parameters**\n- **`delimiter`** *(str)*: String delimiter for csv. Defaults to `,`.\n- **`on_fail`** *(str, Callable)*: The policy to enact when a validator fails.  If `str`, must be one of `reask`, `fix`, `filter`, `refrain`, `noop`, `exception` or `fix_reask`. Otherwise, must be a function that is called when the validator fails.\n\u003c/ul\u003e\n\u003cbr/\u003e\n\n**`validate(self, value, metadata) -\u003e ValidationResult`**\n\u003cul\u003e\nValidates the given `value` using the rules defined in this validator, relying on the `metadata` provided to customize the validation process. This method is automatically invoked by `guard.parse(...)`, ensuring the validation logic is applied to the input data.\n\nNote:\n\n1. This method should not be called directly by the user. Instead, invoke `guard.parse(...)` where this method will be called internally for each associated Validator.\n2. When invoking `guard.parse(...)`, ensure to pass the appropriate `metadata` dictionary that includes keys and values required by this validator. If `guard` is associated with multiple validators, combine all necessary metadata into a single dictionary.\n\n**Parameters**\n- **`value`** *(Any):* The input value to validate.\n- **`metadata`** *(dict):* A dictionary containing metadata required for validation. No additional metadata keys are needed for this validator.\n\u003c/ul\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyparam%2Fcsv-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyparam%2Fcsv-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyparam%2Fcsv-validator/lists"}