Sha256: 9146b236d53898a587ecedb5e582372e14646e073277340721b4bd4e868be3e2
Contents?: true
Size: 764 Bytes
Versions: 3
Compression:
Stored size: 764 Bytes
Contents
def cards_of_type_exist? !new_card? && Card.where(trash: false, type_id: id).exists? end def create_ok? Card.new(type_id: id).ok? :create end def was_cardtype? type_id_before_act == Card::CardtypeID end event :check_for_cards_of_type, after: :validate_delete do errors.add :cardtype, tr(:cards_exist, cardname: name) if cards_of_type_exist? end event :check_for_cards_of_type_when_type_changed, :validate, changing: :type, when: :was_cardtype? do if cards_of_type_exist? errors.add :cardtype, tr(:error_cant_alter, name: name_before_act) end end event :validate_cardtype_name, :validate, on: :save, changed: :name do if %r{[<>/]}.match?(name) errors.add :name, tr(:error_invalid_character_in_cardtype, banned: "<, >, /") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
card-1.101.3 | mod/core/set/type/cardtype.rb |
card-1.101.2 | mod/core/set/type/cardtype.rb |
card-1.101.1 | mod/core/set/type/cardtype.rb |