{"id":15713559,"url":"https://github.com/ragmaanir/vagt","last_synced_at":"2025-03-30T18:47:05.018Z","repository":{"id":238380989,"uuid":"685156913","full_name":"Ragmaanir/vagt","owner":"Ragmaanir","description":"Crystal validations","archived":false,"fork":false,"pushed_at":"2023-08-30T16:27:38.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T18:46:32.045Z","etag":null,"topics":["crystal","validation","validation-library"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/Ragmaanir.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":"2023-08-30T16:26:59.000Z","updated_at":"2023-10-03T09:07:26.000Z","dependencies_parsed_at":"2024-05-06T00:05:00.532Z","dependency_job_id":"b1bcc600-6460-4e60-a6c5-474d66a7d2f1","html_url":"https://github.com/Ragmaanir/vagt","commit_stats":null,"previous_names":["ragmaanir/vagt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fvagt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fvagt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fvagt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fvagt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ragmaanir","download_url":"https://codeload.github.com/Ragmaanir/vagt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365639,"owners_count":20765546,"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":["crystal","validation","validation-library"],"created_at":"2024-10-03T21:32:05.771Z","updated_at":"2025-03-30T18:47:04.712Z","avatar_url":"https://github.com/Ragmaanir.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vagt\n\nSimple validations for objects.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     vagt:\n       github: ragmaanir/vagt\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"vagt\"\n\nclass User\n  include Vagt::Validated\n\n  schema do\n    field name : String\n    field age : Int32\n  end\n\n  def initialize(@name, @age)\n  end\nend\n\nclass UserValidator\n  include Vagt::Validator(User)\n\n  BLACKLIST = %w{Admin admin null delete}\n\n  validate :name, format: /\\A[a-zA-Z]+\\z/, size: (2..64), blacklist: BLACKLIST\n  validate :age, range: (13..150)\nend\n\nu = User.new(\"Admin\", 300)\n\ne = UserValidator.call(u).not_nil!\n\nassert e[\"name\"].map(\u0026.name) == [\"blacklist\"]\nassert e[\"age\"].map(\u0026.name) == [\"range\"]\n\nassert e.to_json == \u003c\u003c-JSON\n{\n  \"name\": \"object_invalid\",\n  \"attributes\": {},\n  \"errors\": {\n    \"name\": [\n      {\n        \"name\": \"blacklist\",\n        \"attributes\": {}\n      }\n    \"age\": [\n      {\n        \"name\": \"range\",\n        \"attributes\": {}\n      }\n    ]\n  }\n}\nJSON\n```\n\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/ragmaanir/vagt/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Ragmaanir](https://github.com/ragmaanir) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragmaanir%2Fvagt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fragmaanir%2Fvagt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragmaanir%2Fvagt/lists"}