# File lib/zombie_battleground/api/validation_helper.rb, line 209 def primary_skill_id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :primary_skill_id, value: primary_skill_id) end
module ZombieBattleground::Api::ValidationHelper
Validation helpers for sanitizing inputs and ouputs
Private Instance Methods
Appends an error to the model if ability is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 809 def ability_is_a_string value_is_a_string(target: :ability, value: ability) end
Appends an error to the model if ability is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 819 def ability_is_a_string_and_not_null value_is_a_string(target: :ability, value: ability, nullable: false) end
Appends an error to the model if amount is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 349 def amount_is_a_non_negative_integer value_is_a_non_negative_integer(target: :amount, value: amount) end
Appends an error to the model if amount is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 359 def amount_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :amount, value: amount, nullable: false) end
Appends an error to the model if block_height is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 429 def block_height_is_a_non_negative_integer value_is_a_non_negative_integer(target: :block_height, value: block_height) end
Appends an error to the model if block_height is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 439 def block_height_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :block_height, value: block_height, nullable: false) end
Appends an error to the model if card_name is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 329 def card_name_is_a_string value_is_a_string(target: :card_name, value: card_name) end
Appends an error to the model if card_name is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 339 def card_name_is_a_string_and_not_null value_is_a_string(target: :card_name, value: card_name, nullable: false) end
Appends an error to the model if cost is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 789 def cost_is_a_non_negative_integer value_is_a_non_negative_integer(target: :cost, value: cost) end
Appends an error to the model if cost is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 799 def cost_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :cost, value: cost, nullable: false) end
Appends an error to the model if created_at is not a Time
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 389 def created_at_is_a_time value_is_a_time(target: :created_at, value: created_at) end
Appends an error to the model if created_at is not a Time or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 399 def created_at_is_a_time_and_not_null value_is_a_time(target: :created_at, value: created_at, nullable: false) end
Appends an error to the model if damage is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 749 def damage_is_a_non_negative_integer value_is_a_non_negative_integer(target: :damage, value: damage) end
Appends an error to the model if damage is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 759 def damage_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :damage, value: damage, nullable: false) end
Appends an error to the model if deck_id is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 149 def deck_id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :deck_id, value: deck_id) end
Appends an error to the model if deck_id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 159 def deck_id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :deck_id, value: deck_id, nullable: false) end
Appends an error to the model if description is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 649 def description_is_a_string value_is_a_string(target: :description, value: description) end
Appends an error to the model if description is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 659 def description_is_a_string_and_not_null value_is_a_string(target: :description, value: description, nullable: false) end
Appends an error to the model if frame is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 729 def frame_is_a_string value_is_a_string(target: :frame, value: frame) end
Appends an error to the model if frame is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 739 def frame_is_a_string_and_not_null value_is_a_string(target: :frame, value: frame, nullable: false) end
Appends an error to the model if health is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 769 def health_is_a_non_negative_integer value_is_a_non_negative_integer(target: :health, value: health) end
Appends an error to the model if health is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 779 def health_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :health, value: health, nullable: false) end
Appends an error to the model if hero_id is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 189 def hero_id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :hero_id, value: hero_id) end
Appends an error to the model if hero_id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 199 def hero_id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :hero_id, value: hero_id, nullable: false) end
Appends an error to the model if id is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 109 def id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :id, value: id) end
Appends an error to the model if id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 119 def id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :id, value: id, nullable: false) end
Appends an error to the model if image_url is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 829 def image_url_is_a_string value_is_a_string(target: :image_url, value: image_url) end
Appends an error to the model if image_url is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 839 def image_url_is_a_string_and_not_null value_is_a_string(target: :image_url, value: image_url, nullable: false) end
Appends an error to the model if kind is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 609 def kind_is_a_string value_is_a_string(target: :kind, value: kind) end
Appends an error to the model if kind is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 619 def kind_is_a_string_and_not_null value_is_a_string(target: :kind, value: kind, nullable: false) end
Appends an error to the model if limit is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 309 def limit_is_a_non_negative_integer value_is_a_non_negative_integer(target: :limit, value: limit) end
Appends an error to the model if limit is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 319 def limit_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :limit, value: limit, nullable: false) end
Appends an error to the model if mould_id is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 589 def mould_id_is_a_string value_is_a_string(target: :mould_id, value: mould_id) end
Appends an error to the model if mould_id is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 599 def mould_id_is_a_string_and_not_null value_is_a_string(target: :mould_id, value: mould_id, nullable: false) end
Appends an error to the model if name is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 169 def name_is_a_string value_is_a_string(target: :name, value: name) end
Appends an error to the model if name is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 179 def name_is_a_string_and_not_null value_is_a_string(target: :name, value: name, nullable: false) end
Appends an error to the model if page is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 289 def page_is_a_non_negative_integer value_is_a_non_negative_integer(target: :page, value: page) end
Appends an error to the model if page is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 299 def page_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :page, value: page, nullable: false) end
Appends an error to the model if player1_deck_id is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 489 def player1_deck_id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :player1_deck_id, value: player1_deck_id) end
Appends an error to the model if player1_deck_id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 499 def player1_deck_id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :player1_deck_id, value: player1_deck_id, nullable: false) end
Appends an error to the model if player1_id is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 449 def player1_id_is_a_string value_is_a_string(target: :player1_id, value: player1_id) end
Appends an error to the model if player1_id is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 459 def player1_id_is_a_string_and_not_null value_is_a_string(target: :player1_id, value: player1_id, nullable: false) end
Appends an error to the model if player2_deck_id is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 509 def player2_deck_id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :player2_deck_id, value: player2_deck_id) end
Appends an error to the model if player2_deck_id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 519 def player2_deck_id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :player2_deck_id, value: player2_deck_id, nullable: false) end
Appends an error to the model if player2_id is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 469 def player2_id_is_a_string value_is_a_string(target: :player2_id, value: player2_id) end
Appends an error to the model if player2_id is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 479 def player2_id_is_a_string_and_not_null value_is_a_string(target: :player2_id, value: player2_id, nullable: false) end
Appends an error to the model if primary_skill_id is a negative Integer
@return [void]
@api private
Appends an error to the model if primary_skill_id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 219 def primary_skill_id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :primary_skill_id, value: primary_skill_id, nullable: false) end
Appends an error to the model if random_seed is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 529 def random_seed_is_a_non_negative_integer value_is_a_non_negative_integer(target: :random_seed, value: random_seed) end
Appends an error to the model if random_seed is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 539 def random_seed_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :random_seed, value: random_seed, nullable: false) end
Appends an error to the model if rank is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 669 def rank_is_a_string value_is_a_string(target: :rank, value: rank) end
Appends an error to the model if rank is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 679 def rank_is_a_string_and_not_null value_is_a_string(target: :rank, value: rank, nullable: false) end
Appends an error to the model if rarity is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 709 def rarity_is_a_string value_is_a_string(target: :rarity, value: rarity) end
Appends an error to the model if rarity is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 719 def rarity_is_a_string_and_not_null value_is_a_string(target: :rarity, value: rarity, nullable: false) end
Appends an error to the model if secondary_skill_id is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 229 def secondary_skill_id_is_a_non_negative_integer value_is_a_non_negative_integer(target: :secondary_skill_id, value: secondary_skill_id) end
Appends an error to the model if secondary_skill_id is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 239 def secondary_skill_id_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :secondary_skill_id, value: secondary_skill_id, nullable: false) end
Appends an error to the model if sender_address is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 369 def sender_address_is_a_string value_is_a_string(target: :sender_address, value: sender_address) end
Appends an error to the model if sender_address is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 379 def sender_address_is_a_string_and_not_null value_is_a_string(target: :sender_address, value: sender_address, nullable: false) end
Appends an error to the model if set is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 629 def set_is_a_string value_is_a_string(target: :set, value: set) end
Appends an error to the model if set is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 639 def set_is_a_string_and_not_null value_is_a_string(target: :set, value: set, nullable: false) end
Appends an error to the model if status is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 549 def status_is_a_string value_is_a_string(target: :status, value: status) end
Appends an error to the model if status is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 559 def status_is_a_string_and_not_null value_is_a_string(target: :status, value: status, nullable: false) end
Appends an error to the model if total is a negative Integer
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 269 def total_is_a_non_negative_integer value_is_a_non_negative_integer(target: :total, value: total) end
Appends an error to the model if total is a negative Integer or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 279 def total_is_a_non_negative_integer_and_not_null value_is_a_non_negative_integer(target: :total, value: total, nullable: false) end
Appends an error to the model if type is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 689 def type_is_a_string value_is_a_string(target: :type, value: type) end
Appends an error to the model if type is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 699 def type_is_a_string_and_not_null value_is_a_string(target: :type, value: type, nullable: false) end
Appends an error to the model if updated_at is not a Time
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 409 def updated_at_is_a_time value_is_a_time(target: :updated_at, value: updated_at) end
Appends an error to the model if updated_at is not a Time or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 419 def updated_at_is_a_time_and_not_null value_is_a_time(target: :updated_at, value: updated_at, nullable: false) end
Appends an error to the model if user_id is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 129 def user_id_is_a_string value_is_a_string(target: :user_id, value: user_id) end
Appends an error to the model if user_id is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 139 def user_id_is_a_string_and_not_null value_is_a_string(target: :user_id, value: user_id, nullable: false) end
Appends an error to the model if the value is not the expected class
@param target [Symbol] @param value [Object] @param nullable [Boolean] @param klass [Class]
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 21 def value_is_a_class(target:, value:, nullable:, klass:) return if (nullable && value.nil?) || value.is_a?(klass) errors.add(target, "#{target} must be a #{klass}") end
Appends an error to the model if the value is a negative Integer
@param target [Symbol] @param value [Object] @param nullable [Boolean]
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 94 def value_is_a_non_negative_integer(target:, value:, nullable: true) value_is_an_integer(target: target, value: value, nullable: nullable) return unless errors.messages.empty? return if nullable && value.nil? return if value.zero? || value.positive? errors.add(target, "#{target} must be not negative") end
Appends an error to the model if the value is not String
@param target [Symbol] @param value [Object] @param nullable [Boolean]
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 37 def value_is_a_string(target:, value:, nullable: true) value_is_a_class( target: target, value: value, nullable: nullable, klass: String ) end
Appends an error to the model if the value is not Time
@param target [Symbol] @param value [Object] @param nullable [Boolean]
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 56 def value_is_a_time(target:, value:, nullable: true) value_is_a_class( target: target, value: value, nullable: nullable, klass: Time ) end
Appends an error to the model if the value is not Integer
@param target [Symbol] @param value [Object] @param nullable [Boolean]
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 75 def value_is_an_integer(target:, value:, nullable: true) value_is_a_class( target: target, value: value, nullable: nullable, klass: Integer ) end
Appends an error to the model if version is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 249 def version_is_a_string value_is_a_string(target: :version, value: version) end
Appends an error to the model if version is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 259 def version_is_a_string_and_not_null value_is_a_string(target: :version, value: version, nullable: false) end
Appends an error to the model if winner_id is not a String
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 569 def winner_id_is_a_string value_is_a_string(target: :winner_id, value: winner_id) end
Appends an error to the model if winner_id is not a String or nil
@return [void]
@api private
# File lib/zombie_battleground/api/validation_helper.rb, line 579 def winner_id_is_a_string_and_not_null value_is_a_string(target: :winner_id, value: winner_id, nullable: false) end