Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-14 00:07:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-14 00:07:31 +0300
commit3f0848998ef99206e80ead8c68a50b5889d2ae19 (patch)
tree22e35b606174c38e5ed3bdf3bad0a2dd27cede04 /app/validators
parent5248c5e2212b8e42b28b23e6839d69db0006829b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/iso8601_date_validator.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/validators/iso8601_date_validator.rb b/app/validators/iso8601_date_validator.rb
new file mode 100644
index 00000000000..2b4682f0572
--- /dev/null
+++ b/app/validators/iso8601_date_validator.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class Iso8601DateValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ Date.iso8601(record.read_attribute_before_type_cast(attribute).to_s)
+ rescue ArgumentError, TypeError
+ record.errors.add(attribute, _('must be in ISO 8601 format'))
+ end
+end