https://github.com/fsaldivar-dev/experimental-annotation-swift
El objetivo del repositorio es poder usar un conjunto de anotaciones "property wrappers" a un atributo.
https://github.com/fsaldivar-dev/experimental-annotation-swift
ios-app ios-swift property-wrapper swift
Last synced: about 1 year ago
JSON representation
El objetivo del repositorio es poder usar un conjunto de anotaciones "property wrappers" a un atributo.
- Host: GitHub
- URL: https://github.com/fsaldivar-dev/experimental-annotation-swift
- Owner: fsaldivar-dev
- License: mit
- Created: 2021-07-31T20:14:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-08-03T12:24:42.000Z (almost 4 years ago)
- Last Synced: 2024-03-15T02:45:58.222Z (over 2 years ago)
- Topics: ios-app, ios-swift, property-wrapper, swift
- Language: Swift
- Homepage:
- Size: 287 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE.md
Awesome Lists containing this project
README
# experimental-annotation-swift



[](https://github.com/fsaldivar-dev/experimental-annotation-swift/stargazers)


[](https://github.com/fsaldivar-dev/experimental-annotation-swift/actions/workflows/Build.yml)
[](https://github.com/fsaldivar-dev/experimental-annotation-swift/actions/workflows/UnitTest.yml)
# Coverage
Total Coverage: 92.39%
Coverage ReportFileBranchesFuncsLinesUncovered LinesSources experimental_annotation.swift100%75%78.57%15, 16, 17, 19, 20, 21Sources/annotations EmailAnnotation.swift100%100%100% LengthAnnotation.swift100%100%100% LowCaseAnnotation.swift100%75%90.91%20
Librería que se usa para anidar anotaciones
# Roadmap
| Roadmap | Estado |
| ------------- | ------------- |
| Crear código base | :white_check_mark: |
| SwiftPackage | :white_check_mark: |
| [CocoaPods](https://cocoapods.org) | :white_check_mark: |
| Example | :white_check_mark: |
| UnitTest | :white_check_mark: |
| [Documentación](https://fsaldivar-dev.github.io/experimental-annotation-swift/documentation/annotationswift/) | :rocket: |
| Extensiones | [ ] |
### Swift Package Manager
Swift Package Manager es una herramienta para automatizar la distribución de código Swift y está integrado en el compilador Swift. Está en desarrollo temprano, pero experimental-annotation-swift admite su uso en plataformas compatibles.
Una vez que haya configurado su paquete Swift, agregar experimental-annotation-swift como dependencia es tan fácil como agregarlo al valor de dependencias de su Package.swift.
```swift
dependencies: [
.package(url: "https://github.com/JavierSaldivarRubio/esperimental-annotation-swift", .upToNextMajor(from: "0.0.1"))
]
```
### CocoaPods
[CocoaPods](https://cocoapods.org) es un administrador de dependencias para proyectos Cocoa. Para obtener instrucciones de uso e instalación, visite su sitio web. Para integrar AnnotationSwift en su proyecto Xcode usando CocoaPods, especifíquelo en su `Podfile`:
```ruby
pod 'AnnotationSwift'
```
### Teoría
En java se conoce ya desde hace mucho tiempo las funciones denominadas anotaciones las cuales son muy comunes en sprint, o al usar la serialización con gson en android, en iOS no existía si no hace pocos años el uso de [**property wrappers**](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617)
Si bien es muy similar a las anotaciones de java, aun son muy simples y su principal limitante es que no se puede usar más de una anotación en una variable,
```swift
@Upercase
@MaxLenght(10) //(X) Error Property type 'String?' does not match that of the 'wrappedValue' property of its wrapper type 'Email'
var name: String?
```
la intención de esta librería es poder crear grupos de annotaciones para cualquier fin.
Ejemplo:
```swift
struct Model {
@GroupSet(Email(),
LowCase())
var email: String?
@GroupSet(MinLength(minLength: 3),
MaxLength(maxLength: 10))
var min3Max10: String?
}
````
Se puede observar un modelo donde al attributo `email` se le agregan dos restricciones, la primera es que se requiere ser de tipo *email*, la segunda es que necesita que el string sea minusculas, si yo agrego `FSALDIVAR_DEV@example.com` el valor sera cambiado por `fsaldivar_dev@example.com`