Sha256: 71a092cee246656f91110566f2a02614dd19cf7fa6e87b0d03e948b9de70271e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# -*- coding: utf-8 -*-

if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
  module DataMapper
    module Validate
      module Fixtures
        class Organisation
          include DataMapper::Resource

          property :id, Serial
          property :name, String
          property :domain, String, :unique_index => true

          validates_is_unique :domain, :allow_nil => true
        end

        class Department
          include DataMapper::Resource

          property :id, Serial
          property :name, String, :unique_index => true

          validates_is_unique :name
        end

        class User
          include DataMapper::Resource

          property :id, Serial
          property :user_name, String

          belongs_to :organisation
          belongs_to :department

          validates_is_unique :user_name, :when => :signing_up_for_department_account,   :scope => [:department]
          validates_is_unique :user_name, :when => :signing_up_for_organization_account, :scope => [:organisation]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-validations-0.10.2 spec/fixtures/corporate_world.rb