{"id":16684159,"url":"https://github.com/alozavr/dginputfield","last_synced_at":"2026-05-18T13:10:04.868Z","repository":{"id":77994705,"uuid":"119650687","full_name":"Alozavr/DGInputField","owner":"Alozavr","description":"DGInputField. Formattable and validatable UITextField with care of cursor position","archived":false,"fork":false,"pushed_at":"2018-02-03T08:28:39.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T10:47:57.525Z","etag":null,"topics":["caret-position","ios","swift","textfield","textformatter","validations"],"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/Alozavr.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}},"created_at":"2018-01-31T07:26:03.000Z","updated_at":"2019-10-26T14:49:34.000Z","dependencies_parsed_at":"2023-02-25T15:00:20.542Z","dependency_job_id":null,"html_url":"https://github.com/Alozavr/DGInputField","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Alozavr/DGInputField","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alozavr%2FDGInputField","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alozavr%2FDGInputField/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alozavr%2FDGInputField/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alozavr%2FDGInputField/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alozavr","download_url":"https://codeload.github.com/Alozavr/DGInputField/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alozavr%2FDGInputField/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33178814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["caret-position","ios","swift","textfield","textformatter","validations"],"created_at":"2024-10-12T14:28:31.945Z","updated_at":"2026-05-18T13:10:04.833Z","avatar_url":"https://github.com/Alozavr.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DGInputField\n\nHi! This is a simple `UITextField` sublass that handles formatting, input validation and cursor position for you! \n\n# Installation\nJust put `DGInputField` folder into your project!\n\n# Usage\nYou can just make your textfield of `DGInputField` class in your storyboard or just create it programmatically\n![](https://1.downloader.disk.yandex.ru/disk/cd42120924e30967b54c32b23dc87d9fe7b513bb54041f947efc4c03b2e6ed46/5a75a71b/m0kdPLcqPxFCbBOI0Q_ZdNta87kWAdaEX8ixyE8dAw7l26TRMAveY96DI3_J7yj1apqzssCOMqEtKB3Fi-dZ4Q%3D%3D?uid=0\u0026filename=Screen%20Shot%202018-02-03%20at%2011.10.45.png\u0026disposition=inline\u0026hash=\u0026limit=0\u0026content_type=image%2Fpng\u0026fsize=135929\u0026hid=2ba76a05ae73c7a78b656b480a9f2c82\u0026media_type=image\u0026tknv=v2\u0026etag=4d1b9bcf8a294ba06d40750c8a71c8e6)\n\n`DGInputField` takes delegation of `UITextField` that's why you should not override `delegate` property. Another delegate is provided: \n```swift\npublic protocol DGInputFieldDelegate: UITextFieldDelegate {\n    func textDidChange(in textField: DGInputField, formattedText: String, unformattedText: String)\n}\n```\nIf you do not specify formatter, then `formattedText` will be equal to `unformattedText`\n\n# Formatting\n\nTo add formatting for your input you should implement `StringFormatterProtocol` :\n```swift\npublic protocol StringFormatterProtocol {\n    func format(_ string: String) -\u003e String\n    func removeFormat(_ string: String) -\u003e String\n}\n```\nYou can look an example in demo project. There is `CardNumberFormatter` to format input in groups of 4\n# Validating\n\nFor now validation is made to prevent incorrect input. Perhaps it will be reworked in future. Just like formatting to support validation you just implement protocol `InputStringValidatorProtocol`:\n```swift\npublic protocol InputStringValidatorProtocol {\n    func isValid(string: String) -\u003e Bool\n}\n```\nIf you set both formatter and validator, format is removed before checking string validation.\n\n# Setup\n\nTo set `DGInputField` configuration use `TextFieldConfiguration` like in example: \n```swift\nlet configuration = TextFieldConfiguration(\n            formatter: CardNumberFormatter(),\n            validator: CardNumberInputValidator())\n        creditCardField.setConfiguration(configuration)\n```\nThats it!\n\n# Licensing\nThis repository's code is distributed under **MIT** license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falozavr%2Fdginputfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falozavr%2Fdginputfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falozavr%2Fdginputfield/lists"}