{"id":16978413,"url":"https://github.com/rainmango/validateswift","last_synced_at":"2025-04-12T01:41:42.107Z","repository":{"id":56925862,"uuid":"182246178","full_name":"RainManGO/ValidateSwift","owner":"RainManGO","description":"ValidateSwift  ValidateText","archived":false,"fork":false,"pushed_at":"2019-10-11T07:35:14.000Z","size":685,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T13:00:15.184Z","etag":null,"topics":["validate","validaterswift","validator"],"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/RainManGO.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":"2019-04-19T10:14:14.000Z","updated_at":"2021-08-25T08:54:27.000Z","dependencies_parsed_at":"2022-08-21T06:20:12.628Z","dependency_job_id":null,"html_url":"https://github.com/RainManGO/ValidateSwift","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RainManGO%2FValidateSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RainManGO%2FValidateSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RainManGO%2FValidateSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RainManGO%2FValidateSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RainManGO","download_url":"https://codeload.github.com/RainManGO/ValidateSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505758,"owners_count":21115352,"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":["validate","validaterswift","validator"],"created_at":"2024-10-14T01:43:22.503Z","updated_at":"2025-04-12T01:41:42.089Z","avatar_url":"https://github.com/RainManGO.png","language":"Swift","readme":"# ValidateSwift\n\n[![CI Status](https://img.shields.io/travis/776210576@qq.com/ValidateSwift.svg?style=flat)](https://travis-ci.org/776210576@qq.com/ValidateSwift)\n\u003ca href=\"https://github.com/RainManGO/ValidateSwift\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-Swift%204-orange.svg\"\u003e\u003c/a\u003e\n[![Version](https://img.shields.io/cocoapods/v/ValidateSwift.svg?style=flat)](https://cocoapods.org/pods/ValidateSwift)\n[![License](https://img.shields.io/cocoapods/l/ValidateSwift.svg?style=flat)](https://cocoapods.org/pods/ValidateSwift)\n[![Platform](https://img.shields.io/cocoapods/p/ValidateSwift.svg?style=flat)](https://cocoapods.org/pods/ValidateSwift)\n\n![image](https://github.com/RainManGO/ValidateSwift/blob/master/Validate1.gif)\n\n\n\n## 简介\n\n使用起来超级简单的text验证框架，从此远离一堆代码验证一个表单。\n\n\n\n## 示例\n\n详细例子可以运行示例程序查看，克隆这个仓库，在Example文件夹下执行`pod install`\n\n\n\n## 支持\n\n- iOS 8.0\n- Swift4.0+\n\n\n\n## CocoaPods安装\n\nPodfile里添加：\n\n```ruby\npod 'ValidateSwift'\n```\n\n\n\n## 使用\n\n\n\n### 单个TextFlied\n\n- 如果只需要验空\n\n  ```swift\n  passwordText.validate(emptyInfo: \"请输入XX\")\n  ```\n\n   emptyInfo参数可以不填，默认提示placeholder\n\n- 规则验证\n\n  ```swift\n   phoneText.validate(rulers: [Rulers.required,Rulers.phone]\n  ```\n\n\n\n### 多个TextFlied\n\n首先需要遵守`ValidateAble`协议\n\n```swift\nclass ValidateArrayViewController:ValidateAble{\n\n}\n```\n\n\n\n- 如果只需要验空\n\n  ```swift\n   if validateTexts(textsArray: [nameText,phoneText,emailText]){\n         \n   }\n  ```\n\n  更简单的方式，你还可以使用：(会深度遍历所有self.view的子TextFlied，如果没有就提示placeholder)\n\n  ```swift\n  if checkSubmitView(self.view){\n              \n  }\n  ```\n\n  \n\n- 规则验证\n\n  ```swift\n  if validateTexts(rulerTexts: getRulerText()) {\n             \n  }\n  \n  func getRulerText() -\u003e [RulerText] {\n           let passwordRulerText = RulerText.init(textfelid: passwordText, textRulers: [Rulers.required,Rulers.okpwd], emptyInfo: \"请输入密码\")\n  \n          let phoneRulerText = RulerText.init(textfelid: phoneText, textRulers: [Rulers.required,Rulers.phone])\n  \n          let emailRulerText = RulerText.init(textfelid: emailText, textRulers: [Rulers.required,Rulers.email])\n  \n          let idcardRulerText = RulerText.init(textfelid: idcardText, textRulers: [Rulers.required,Rulers.idcard])\n  \n          let numberRulerText = RulerText.init(textfelid: numberText, textRulers: [Rulers.number])\n  \n          return [passwordRulerText,phoneRulerText,emailRulerText,idcardRulerText,numberRulerText]\n   }\n  \n  ```\n\n  \n\n### 目前支持规则\n\n```swift\npublic enum Rulers:Int{\n    case required = 0\n    case phone\n    case email\n    case okpwd\n    case idcard\n    case bankcard\n    case number\n}\n```\n\n希望可以共同维护，遇到的多种规则，让它越来越强大，让验证越来越简单。\n\n\n\n## License\n\nValidateSwift is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainmango%2Fvalidateswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frainmango%2Fvalidateswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainmango%2Fvalidateswift/lists"}