Sha256: e87aae4a2e00a1e7499fee54c4ab903cdb9c61dd210dd633d5de27330b8bcd38
Contents?: true
Size: 747 Bytes
Versions: 16
Compression:
Stored size: 747 Bytes
Contents
module Formstrap 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
Version data entries
16 entries across 16 versions & 1 rubygems