From 1a070fa80d03af338248fbc32680ed6e9780e00d Mon Sep 17 00:00:00 2001 From: Alexis Reigel <mail@koffeinfrei.org> Date: Thu, 31 May 2018 18:13:04 +0200 Subject: [PATCH] document model validation --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 19b9804..2623a12 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,20 @@ import = UserImport.new import.run # calls User.create!(row) for each row ``` +### Model validation + +A summary of the `ActiveRecord` model validations is available after running +the importer. The `Error` objects indicates the failed excel row and the +corresponding errors. + +```ruby +import = UserImport.new +import.run + +import.errors[:model] +# => [#<struct Excelsior::Error row=3, errors=["First name can't be blank"]>] +``` + ### Extended API You may want to pass an excel file per instance. You can also define your own -- GitLab