Commit 9f45c801 authored by Grigor Aghabalyan's avatar Grigor Aghabalyan
Browse files

Fix: error messages when create form

parent db10f22f
......@@ -17,7 +17,7 @@ class CheckBaseHelper {
let alert = AlertControllerHelper.showAlert(title: "Bed request", message: nil)
viewController.present(alert, animated: true, completion: nil)
case .validationProblem(error: let error):
let alert = AlertControllerHelper.showAlert(title: "Սխալ", message: nil)
let alert = AlertControllerHelper.showAlert(title: error.title, message: error.invalidParams.first?.messages?.first)
viewController.present(alert, animated: true, completion: nil)
case .unauthorized:
let alert = AlertControllerHelper.showAlert(title: "Invalid credentials", message: nil)
......
......@@ -10,10 +10,11 @@ import Foundation
import ObjectMapper
class ValidationError: Mappable {
var type: String = ""
var title: String = ""
var detail: String = ""
var invalidParams: [InvalidParam] = []
var invalidParams: [ValidationErrorFields] = []
required init?(map: Map) {
......@@ -21,9 +22,26 @@ class ValidationError: Mappable {
func mapping(map: Map) {
type <- map["type"]
title <- map["title"]
title <- map["error.message"]
detail <- map["detail"]
invalidParams <- map["invalidParams"]
invalidParams <- map["error.fields"]
}
}
class ValidationErrorFields: Mappable {
var key: String?
var messages: [String]?
required init?(map: Map) {
}
func mapping(map: Map) {
key <- map["key"]
messages <- map["messages"]
}
}
......
......@@ -27,7 +27,6 @@ class DatePickerViewController: UIViewController {
datePickerView.datePickerMode = .time
datePickerView.locale = Locale(identifier: "hy")
}
func getData(callback: @escaping (String?) -> ()) {
......@@ -46,6 +45,7 @@ class DatePickerViewController: UIViewController {
selectedDate = String(format: "%02d:%02d", hour, minute)
}
}
@IBAction func okButtonAction(_ sender: UIButton) {
self.dismisView()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment