{"id":16482818,"url":"https://github.com/shaps80/warrant","last_synced_at":"2025-03-21T07:30:50.906Z","repository":{"id":23368897,"uuid":"26730175","full_name":"shaps80/Warrant","owner":"shaps80","description":"Data validation made easy. In code and from Interface Builder.","archived":false,"fork":false,"pushed_at":"2017-02-28T12:36:45.000Z","size":1948,"stargazers_count":54,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T03:05:53.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","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/shaps80.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}},"created_at":"2014-11-16T22:22:33.000Z","updated_at":"2023-05-15T19:24:56.000Z","dependencies_parsed_at":"2022-08-05T22:16:15.773Z","dependency_job_id":null,"html_url":"https://github.com/shaps80/Warrant","commit_stats":null,"previous_names":["shaps80/spxdatavalidators"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FWarrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FWarrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FWarrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FWarrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaps80","download_url":"https://codeload.github.com/shaps80/Warrant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244757311,"owners_count":20505371,"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-10-11T13:12:07.252Z","updated_at":"2025-03-21T07:30:50.499Z","avatar_url":"https://github.com/shaps80.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"assets/logo.png\" width=\"128\"\u003e\n\n# Warrant\n\n[![CI Status](http://img.shields.io/travis/shaps80/Warrant.svg?style=flat)](https://travis-ci.org/shaps80/Warrant.svg?branch=master)\n[![Version](https://img.shields.io/cocoapods/v/Warrant.svg?style=flat)](http://cocoadocs.org/docsets/Warrant)\n[![License](https://img.shields.io/cocoapods/l/Warrant.svg?style=flat)](http://cocoadocs.org/docsets/Warrany)\n[![Platform](https://img.shields.io/cocoapods/p/Warrant.svg?style=flat)](http://cocoadocs.org/docsets/Warrant)\n\n\u003cimg src=\"assets/IB.png\" width=\"720\" height=\"160\" /\u003e\n\nData validation made easy. In code and from Interface Builder.\n\nWarrant aims to remove validation from your code, centralize common validation patterns and make your validations more compositable.\n\nWarrant makes data validation better by following best practices:\n\n* Single Responsibility Principle\n* Separation of Concerns\n* Composition\n* Reusability\n\n## Validators\n \nWarrant provides four validators by default:\n\n* RegexValidator\n* EmailValidator\n* BlockValidator\n* CompoundValidator (using `.All` or `.Any` rules)\n\nValidators also use Swift's new error handling features, making it easy to use in code.\n\n## View Validators\n\nWarrant also provides validation support for three view types by default:\n\n* UITextField\n* UITextView\n* UITableViewCell\n* UIButton\n\nWarrant also makes use of `@IBInspectable`, giving you access to common configuration options through IB.\n\nSee the example app or the screenshot above to learn how you can use this feature.\n\n## Dependencies\n\nWarrant even supports dependant fields. So with zero code, you can configure a view to validate based on its validator in addition to other dependant views. See the example Sign In app to see how this works.\n\n## Extending Warrant\n\nWarrant follows a protocol oriented approach, making it easy to add your own validators.\n\nIf you want to create a new validator, you can either comform to the `Validating` protocol or subclass `Validator` (recommended) directly.\n\nIf instead you want extend a UIView (or subclass) to support validation, you just need to make it conform to `ViewValidating`. Now you can use it from code or IB and gain all the benefits and power from Warrant.\n\t\n## Code\n\nIf you prefer to setup your validators in code:\n\n``` swift\nlet validator = EmailValidator()\nvalidator.regexPattern = ...\ndo {\n  validator.validate(email)\n} catch { print(error) }\n```\n\nIf you want to configure a view with depenedencies, you can set that up like so:\n\n```swift\nbutton.dependantViews = [ emailField, passField ]\n```\n\nValidation is then as simple as:\n\n```swift\ndo {\n  try button.validate()\n} catch { print(error) }\n```\n\n## Compound Validators\n\nWhat if we want to apply multiple validators for a value? Easy, we can either use a compound validator:\n\n```swift\nlet nonEmpty = NonEmptyValidator()\nlet email = EmailValidator()\n    \nlet compound = CompoundValidator(validators: [ nonEmpty, email ])\ndo {\n  try compound.validators?.validate(\"foor@bar.com\", rule: .All)\n} catch { print(error) }\n```\n\nor we use a straight Swift array:\n\n```swift\nlet validators = [ nonEmpty, email ]\nvalidators.validate(\"foo.bar@me.com\", rule: .All)\n```\n\nCompoundValidator are better when configuring via Interface Builder.\n\n_Note: You can also validate multiple views in this way_\n\n## Installation\n\nWarrant is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n    pod 'Warrant'\n    \n## Pull Requests\n\nIf you have ideas for really useful, reusable validators, please create a pull request and I'll include them.\n\n## Author\n\nShaps Mohsenin, [@shaps](http://twitter.com/shaps)\n\n## License\n\nWarrant is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Fwarrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaps80%2Fwarrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Fwarrant/lists"}