generated_schema_validations 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd9e8c56b1df3693d2fcf47a61b8904277a1fbfc3c2c0dcf71bc2f30baa30097
|
|
4
|
+
data.tar.gz: 7f68dab0123374dd86106df0f462e5d68fd8ec227938378799aa377bbe281c5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa9eb0de4a2144fe689bd34e5cd63f75853592cf2da93b7a30034f389283b8c401201178c5cfa63ec5d444f58fbe984fc0cce033c1f4baf196619ef3b440f4ad
|
|
7
|
+
data.tar.gz: 6de0ba1f0471ab2d42a907c99031bfbde9595c2a81812877d8713bf74487e99ce93dc827629c4772d19e73bde561d6ff033f71a649e8a22cb42fa2e3ed476a03
|
data/README.md
CHANGED
|
@@ -105,6 +105,11 @@ You can watch changes on `schema_validations.rb` to understand the generated val
|
|
|
105
105
|
|
|
106
106
|
## Changelog
|
|
107
107
|
|
|
108
|
+
### 0.5.4
|
|
109
|
+
|
|
110
|
+
* adds support for time fields
|
|
111
|
+
* fix errors on overflowing column values
|
|
112
|
+
|
|
108
113
|
### 0.5.3
|
|
109
114
|
|
|
110
115
|
* adds support for Rails 7.2
|
|
@@ -104,6 +104,11 @@ class GeneratedSchemaValidations::Table
|
|
|
104
104
|
validates name, :date_in_db_range
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
def time(name, column_options = {})
|
|
108
|
+
null_validation(:time, name, column_options)
|
|
109
|
+
validates name, :time_in_db_range
|
|
110
|
+
end
|
|
111
|
+
|
|
107
112
|
def boolean(name, column_options = {})
|
|
108
113
|
null_validation(:boolean, name, column_options)
|
|
109
114
|
end
|
|
@@ -106,7 +106,7 @@ module SchemaValidations
|
|
|
106
106
|
return unless value.is_a?(DateTime) || value.is_a?(Time)
|
|
107
107
|
return if value.year.between?(-4711, 294_275) # see https://www.postgresql.org/docs/9.3/datatype-datetime.html
|
|
108
108
|
|
|
109
|
-
record.errors.add(attr_name, :invalid
|
|
109
|
+
record.errors.add(attr_name, :invalid)
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
@@ -116,7 +116,23 @@ module SchemaValidations
|
|
|
116
116
|
return unless value.is_a?(Date)
|
|
117
117
|
return if value.year.between?(-4711, 5_874_896) # see https://www.postgresql.org/docs/9.3/datatype-datetime.html
|
|
118
118
|
|
|
119
|
-
record.errors.add(attr_name, :invalid
|
|
119
|
+
record.errors.add(attr_name, :invalid)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
class TimeInDbRangeValidator < ActiveModel::EachValidator
|
|
124
|
+
def validate_each(record, attr_name, value)
|
|
125
|
+
return if value.nil?
|
|
126
|
+
|
|
127
|
+
unless value.is_a?(Time) || value.is_a?(ActiveSupport::TimeWithZone)
|
|
128
|
+
record.errors.add(attr_name, :invalid)
|
|
129
|
+
return
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# PostgreSQL allows only times in one day
|
|
133
|
+
return if value.to_date == Date.new(2000, 1, 1)
|
|
134
|
+
|
|
135
|
+
record.errors.add(attr_name, :invalid)
|
|
120
136
|
end
|
|
121
137
|
end
|
|
122
138
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: generated_schema_validations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Georg Limbach
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: After each migration it generates a file with some validations. Each
|
|
14
14
|
active record should include this file and can uns generated validations.
|