{"id":32150354,"url":"https://github.com/coenttb/swift-password-validation","last_synced_at":"2025-10-21T10:02:03.516Z","repository":{"id":306240575,"uuid":"1025491648","full_name":"coenttb/swift-password-validation","owner":"coenttb","description":"A Swift library for type-safe password validation","archived":false,"fork":false,"pushed_at":"2025-08-02T19:33:11.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-21T10:01:51.948Z","etag":null,"topics":["password-validation","swift"],"latest_commit_sha":null,"homepage":"https://coenttb.com","language":"Swift","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/coenttb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2025-07-24T10:34:10.000Z","updated_at":"2025-08-02T19:33:15.000Z","dependencies_parsed_at":"2025-07-24T15:00:13.569Z","dependency_job_id":"2cba19f2-bd79-4973-8bff-831d56da8c24","html_url":"https://github.com/coenttb/swift-password-validation","commit_stats":null,"previous_names":["coenttb/swift-password-validation"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coenttb/swift-password-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-password-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-password-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-password-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-password-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coenttb","download_url":"https://codeload.github.com/coenttb/swift-password-validation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coenttb%2Fswift-password-validation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280240316,"owners_count":26296527,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["password-validation","swift"],"created_at":"2025-10-21T10:01:14.363Z","updated_at":"2025-10-21T10:02:03.509Z","avatar_url":"https://github.com/coenttb.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PasswordValidation\n\nA flexible and secure password validation library for Swift applications.\n\n## Overview\n\nPasswordValidation provides a composable approach to password validation in Swift. It offers predefined validation rules while allowing custom validation logic to be easily integrated, making it perfect for applications that need robust password security.\n\n## Features\n\n- ✅ **Predefined Validators**: Ready-to-use validation rules for common scenarios\n- ✅ **Custom Validation**: Create your own validation logic with ease\n- ✅ **Dependencies Integration**: Built-in support for the Dependencies library\n- ✅ **Localized Error Messages**: User-friendly error descriptions\n- ✅ **Comprehensive Testing**: Simple and default validators for different environments\n- ✅ **Swift Concurrency**: Full `Sendable` support for modern Swift apps\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/coenttb/swift-password-validation.git\", from: \"0.0.1\")\n]\n```\n\nThen add `PasswordValidation` to your target dependencies:\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"PasswordValidation\", package: \"swift-password-validation\")\n    ]\n)\n```\n\n## Quick Start\n\n### Basic Usage\n\n```swift\nimport PasswordValidation\n\n// Use the comprehensive validator\nlet validator = PasswordValidation.default\n\ndo {\n    let isValid = try validator.validate(\"MySecurePass123!\")\n    print(\"Password is valid: \\(isValid)\")\n} catch let error as PasswordValidation.Error {\n    print(\"Validation failed: \\(error.description)\")\n}\n```\n\n### With Dependencies\n\n```swift\nimport Dependencies\nimport PasswordValidation\n\nstruct LoginService {\n    @Dependency(\\.passwordValidation) var passwordValidation\n    \n    func validateUserPassword(_ password: String) throws -\u003e Bool {\n        return try passwordValidation.validate(password)\n    }\n}\n```\n\n## Predefined Validators\n\n### Default Validator\n\nThe `default` validator implements comprehensive security requirements:\n\n- **Length**: 8-64 characters\n- **Uppercase**: At least one uppercase letter (A-Z)\n- **Lowercase**: At least one lowercase letter (a-z)\n- **Digits**: At least one digit (0-9)\n- **Special Characters**: At least one special character (`!\u0026^%$#@()/`)\n\n```swift\nlet validator = PasswordValidation.default\ntry validator.validate(\"MySecurePass123!\") // ✅ Valid\n```\n\n### Simple Validator\n\nThe `simple` validator has minimal requirements (4+ characters) and is useful for testing:\n\n```swift\nlet validator = PasswordValidation.simple\ntry validator.validate(\"test\") // ✅ Valid\n```\n\n## Custom Validation\n\nCreate your own validation rules:\n\n```swift\nlet customValidator = PasswordValidation { password in\n    guard password.count \u003e= 6 else {\n        throw PasswordValidation.Error.tooShort(minLength: 6)\n    }\n    \n    guard !password.lowercased().contains(\"password\") else {\n        throw PasswordValidation.Error.missingSpecialCharacter\n    }\n    \n    return true\n}\n```\n\n## Error Handling\n\nThe library provides specific error types for different validation failures:\n\n```swift\ndo {\n    try PasswordValidation.default.validate(\"weak\")\n} catch PasswordValidation.Error.tooShort(let minLength) {\n    print(\"Password too short, needs at least \\(minLength) characters\")\n} catch PasswordValidation.Error.missingUppercase {\n    print(\"Password needs an uppercase letter\")\n} catch PasswordValidation.Error.missingDigit {\n    print(\"Password needs a digit\")\n} catch {\n    print(\"Other validation error: \\(error)\")\n}\n```\n\n## Available Errors\n\n- `tooShort(minLength: Int)` - Password is shorter than required\n- `tooLong(maxLength: Int)` - Password exceeds maximum length\n- `missingUppercase` - No uppercase letters found\n- `missingLowercase` - No lowercase letters found  \n- `missingDigit` - No digits found\n- `missingSpecialCharacter` - No special characters found\n\n## Documentation\n\nFor comprehensive documentation including advanced usage examples, visit the [DocC documentation](Sources/PasswordValidation/PasswordValidation.docc/PasswordValidation.md).\n\n## Dependencies\n\nThis library depends on:\n\n- [swift-dependencies](https://github.com/pointfreeco/swift-dependencies) - For dependency injection\n- [swift-translating](https://github.com/coenttb/swift-translating) - For localized error messages\n\n## Feedback is much appreciated!\n\nIf you're working on your own Swift project, feel free to learn, fork, and contribute.\n\nGot thoughts? Found something you love? Something you hate? Let me know! Your feedback helps make this project better for everyone. Open an issue or start a discussion—I'm all ears.\n\n\u003e [Subscribe to my newsletter](http://coenttb.com/en/newsletter/subscribe)\n\u003e\n\u003e [Follow me on X](http://x.com/coenttb)\n\u003e \n\u003e [Link on Linkedin](https://www.linkedin.com/in/tenthijeboonkkamp)\n\n## License\n\nThis project is licensed under the **APACHE 2.0. License**.  \nYou are free to use, modify, and distribute this project under the terms of the APACHE 2.0. License.  \nFor full details, please refer to the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-password-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoenttb%2Fswift-password-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoenttb%2Fswift-password-validation/lists"}