Class: AuctionFunCore::Contracts::AuctionContext::CreateContract

Inherits:
AuctionFunCore::Contracts::ApplicationContract show all
Includes:
Business::Configuration
Defined in:
lib/auction_fun_core/contracts/auction_context/create_contract.rb

Overview

This class is designed to validate the creation of new auctions. It includes various validations such as staff existence, auction kind, timing, and initial bids.

Examples:

Creating a new auction

contract = AuctionFunCore::Contracts::AuctionContext::CreateContract.new
attributes = {
  staff_id: 1,
  title: "Rare Antique Vase",
  kind: "standard",
  started_at: Time.current + 5.days,
  finished_at: Time.current + 10.days,
  initial_bid_cents: 5000
}
result = contract.call(attributes)
if result.success?
  puts "Auction created successfully."
else
  puts "Failed to create auction: #{result.errors.to_h}"
end

Constant Summary collapse

REQUIRED_FINISHED_AT =

Additional validations specific for non-penny auctions.

AUCTION_KINDS - ["penny"]

Constants included from Business::Configuration

Business::Configuration::AUCTION_KINDS, Business::Configuration::AUCTION_MAX_TITLE_LENGTH, Business::Configuration::AUCTION_MIN_TITLE_LENGTH, Business::Configuration::AUCTION_STATUSES, Business::Configuration::AUCTION_STOPWATCH_MAX_VALUE, Business::Configuration::AUCTION_STOPWATCH_MIN_VALUE, Business::Configuration::MAX_NAME_LENGTH, Business::Configuration::MAX_PASSWORD_LENGTH, Business::Configuration::MIN_NAME_LENGTH, Business::Configuration::MIN_PASSWORD_LENGTH

Constants inherited from AuctionFunCore::Contracts::ApplicationContract

AuctionFunCore::Contracts::ApplicationContract::EMAIL_REGEX, AuctionFunCore::Contracts::ApplicationContract::I18N_MACRO_SCOPE