Sha256: 437f8230b701e5531f1d6e6c89076776e1df7bcbe2d7c8ee3b1ef09ba8af943c

Contents?: true

Size: 449 Bytes

Versions: 2

Compression:

Stored size: 449 Bytes

Contents

# frozen_string_literal: true
module Decidim
  module Comments
    # A form object used to create comments from the graphql api.
    #
    class CommentForm < Form
      attribute :body, String
      attribute :alignment, Integer
      attribute :user_group_id, Integer

      mimic :comment

      validates :body, presence: true
      validates :alignment, inclusion: { in: [0, 1, -1] }, if: ->(form) { form.alignment.present? }
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
decidim-comments-0.0.3 app/forms/decidim/comments/comment_form.rb
decidim-0.0.3 decidim-comments/app/forms/decidim/comments/comment_form.rb