Sha256: 39fd8561500b263f0c982c5beef9dd4482dc61968530605ad7e4b67bc105244e
Contents?: true
Size: 823 Bytes
Versions: 17
Compression:
Stored size: 823 Bytes
Contents
module Headmin module Form module Validatable extend ActiveSupport::Concern included do def validation_options { id: validation_id, message: validation_message, valid: valid? } end def validate? form.object&.errors&.any? end private def valid? !form.object&.errors&.has_key?(attribute) end def validation_message form.object&.errors&.full_messages_for(attribute)&.join(", ") end def validation_id [attribute.to_s, "validation"].join("_").parameterize.underscore end def validation_class return unless validate? valid? ? "is-valid" : "is-invalid" end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems