Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork0
A Swift implementation of validation helpers for identifier strings.
License
ATProtoKit/ATSyntaxTools
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Syntax validators for the AT Protocol, written in Swift.
ATSyntaxTools is a lightweight Swift library for handling validations for various identifiers within the AT Protocol. It's fast, simple, and leaves an extremely small footprint in your project. This package is designed to ensure that you're not passing the wrong infroamtion that could cause your project to crash.
This Swift package mainly focuses on the syntax validation side of the AT Protocol. This is based on thesyntax package from the officialatproto TypeScript repository.
Here are the following identifiers for you to use in this package.
import ATSyntaxToolsdo{letisHandleValid=HandleValidator.isHandleValid("alice.test")print(isHandleValid) // returns `true`.tryHandleValidator.validate("alice.test") // Doesn't throw; handle is valid.letisHandleValid2=HandleValidator.isHandleValid("al!ce.test")print(isHandleValid2) // returns `false`.tryHandleValidator.validate("al!ce.test") // Throws InvalidHandleError.}catch{print(error)}
import ATSyntaxToolsdo{tryDIDValidator.validate("did:method:val") // Doesn't throw; DID is valid.tryDIDValidator.validate(":did:method:val") // Throws InvalidDIDError.}catch{print(error)}
import ATSyntaxToolsdo{tryNSIDValidator.validate("com.example.foo") // Doesn't throw; NSID is valid.tryNSIDValidator.validate("com.example.someRecord") // Doesn't throw; NSID is valid.tryNSIDValidator.validate("example.com/foo") // Throws InvalidNSIDError.tryNSIDValidator.validate("foo") // Throws InvalidNSIDError.}catch{print(error)}
import ATSyntaxToolsdo{tryATURIValidator.validate("at://bob.com/com.example.post/1234") // Doesn't throw; AT URI is valid.tryATURIValidator.validate("at:://bob.com/com.examp!e.2/1234") // Throws InvalidATURIError}catch{print(error)}
You can use the Swift Package Manager to download and import the library into your project:
dependencies:[.package(url:"https://github.com/ATProtoKit/ATSyntaxTools.git", from:"0.1.0")]
Then undertargets:
targets:[.target( // name: "[name of target]", dependencies:[.product(name:"ATSyntaxTools",package:"atsyntaxtools")])]
To use ATSyntaxTools in your apps, your app should target the specific version numbers:
- iOS andiPadOS 14 or later.
- macOS 13 or later.
- tvOS 14 or later.
- visionOS 1 or later.
- watchOS 9 or later.
For Linux, you need to use Swift 6.0 or later. On Linux, the minimum requirements include:
- Amazon Linux 2
- Debian 12
- Fedora 39
- Red Hat UBI 9
- Ubuntu 20.04
You can also use this project for any programs you make using Swift and running onDocker.
Warning
As of right now, Windows support is theoretically possible, but not has not been tested to work. Contributions and feedback on making it fully compatible for Windows and Windows Server are welcomed.
While this project will change significantly, feedback, issues, and contributions are highly welcomed and encouraged. If you'd like to contribute to this project, please be sure to read both theAPI Guidelines as well as theContributor Guidelines before submitting a pull request. Any issues (such as bug reports or feedback) can be submitted in theIssues tab. Finally, if there are any security vulnerabilities, please readSECURITY.md for how to report it.
If you have any questions, you can ask me on Bluesky (@cjrriley.ca). And while you're at it, give me a follow! I'm also active on theBluesky API Touchers Discord server.
This Swift package is using the Apache 2.0 License. Please viewLICENSE.md for more details.
About
A Swift implementation of validation helpers for identifier strings.
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.