summaryrefslogtreecommitdiff
path: root/app/validators
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-30 22:02:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-30 22:02:13 +0000
commit516fba52cf280b9d5bad08dce9f0150f859b6cea (patch)
tree4dad71be856651af62c9a281b01087ae15480810 /app/validators
parentc90be62bdefdb6bb67c73a9c4a6d164c9f78a28d (diff)
downloadgitlab-ce-516fba52cf280b9d5bad08dce9f0150f859b6cea.tar.gz
Add latest changes from gitlab-org/security/gitlab@13-4-stable-ee
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/future_date_validator.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/validators/future_date_validator.rb b/app/validators/future_date_validator.rb
new file mode 100644
index 00000000000..1ba4a1e273d
--- /dev/null
+++ b/app/validators/future_date_validator.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# FutureDateValidator
+
+# Validates that a date is in the future.
+#
+# Example:
+#
+# class Member < ActiveRecord::Base
+# validates :expires_at, allow_blank: true, future_date: true
+# end
+
+class FutureDateValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ record.errors.add(attribute, _('cannot be a date in the past')) if value < Date.current
+ end
+end