Comments (7)
Here's a temporary hack for if your fields are laid out from top to bottom:
let errorArray = errors.values.sort({
$0.textField.frame.origin.y < $1.textField.frame.origin.y
})
from swiftvalidator.
I tried @ed-mejia 's suggestion but got the following error (Swift Validator Tag v4.0.0):
Value of type 'ObjectIdentifier' has no member 'frame'
In case anyone else has the same issue, this worked for me:
extension Validator {
typealias ValidatorErrorsTuple = (validatable: Validatable,error: ValidationError)
var errorsOrdered: [(Validatable,ValidationError)] {
get {
let errorArray = errors.map {
(tuple: (identifier: ObjectIdentifier, error: ValidationError)) -> (Validatable, ValidationError) in
return (tuple.error.field,tuple.error)
}.sort { (first: ValidatorErrorsTuple, second: ValidatorErrorsTuple) -> Bool in
if let firstView = first.validatable as? UIView,
secondView = second.validatable as? UIView{
return firstView.frame.origin.y < secondView.frame.origin.y
}
return false
}
return errorArray
}
}
}
from swiftvalidator.
Currently this is not supported.
from swiftvalidator.
Hi, I had the same issue, following @lmcd recommendation I implemented this extension:
//MARK: Validator
extension Validator {
/* this extension/hack was created because the validation library does not provide the returned
ValidationErrors ordered in the same way we added them or in the way they are being displayed on screen */
/// return the errors ordered by the frame (y coordinate)
typealias ValidatorErrorsTuple = (UITextField,ValidationError)
var errorsOrdered: [ValidatorErrorsTuple] {
get {
let errorArray = errors.sort({
$0.0.frame.origin.y < $1.0.frame.origin.y
})
return errorArray
}
}
}
This way we have the _same tuple value_ returned originally by _errors_ property but ordered.
from swiftvalidator.
updated by adding superview
let errorArray = validator.errors.values.sort({
$0.textField.superview?.superview!.frame.origin.y < $1.textField.superview?.superview!.frame.origin.y
})
from swiftvalidator.
I added this code to failed delegate method.
let errorArray = errors.sorted {
($0.0 as! UITextField).frame.origin.y < ($1.0 as! UITextField).frame.origin.y
}
from swiftvalidator.
Declaring Backlog Bankruptcy!
I'm not going to lie this project took off and I'm pretty overwhelmed by it. I no longer actively code in Swift and I need help from more contributors in order to keep this project relevant. I'd like to find someone to transition as lead maintainer or help this codebase find a happy home with a company.
The codebase for this project is relatively small and focused project for who is looking to contribute. It does one thing, and does it pretty well. It has pretty high test coverage and good adoption. I think my ideal maintainer / contributor would work for a company that actively uses SwiftValidator in their production application.
If you're interested in helping out please comment on #204
from swiftvalidator.
Related Issues (20)
- swiftValidator compatible Swift 3.2 ? HOT 1
- Has this project been abandoned? HOT 1
- Add minimum Date Rule, Social Security Number Rule, and Routing Number Rule
- Interested in becoming a contributor HOT 3
- Set all provided error labels as hidden - new property
- 'ViewController' does not conform to protocol 'ValidationDelegate' HOT 2
- Cannot call value of non-function type 'ValidatorDictionary<ValidationRule>'
- Podspec version HOT 1
- CharacterSetRule didn't marked as "open"
- pods osx support
- library not updated for swift 4, gives issues HOT 1
- Add support for Swift 5.0 HOT 1
- Error: An empty identity is not valid when signing a binary for the product type 'Application'. (in target 'Validator') HOT 10
- ValidationResult error
- Swift package manager support HOT 1
- getting an error "Ambiguous use of 'validate'" HOT 1
- upgrade to swift 5?
- HIPAA policy compliance
- Need to add min-max amount rule
- Need to update podspec file to use version 5.0.0 via cocoapods.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftvalidator.