Sha256: fe40c5df5e691aa427a71b1a229ca440c66259cdf3e5b72ebd61e8e62f421d7e

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

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

module DataMapper
  module Validations
    module Fixtures
      class BillOfLading
        #
        # Behaviors
        #

        include DataMapper::Resource

        #
        # Properties
        #

        property :id,       Serial

        property :doc_no,   String, :auto_validation => false
        property :email,    String, :auto_validation => false
        property :username, String, :auto_validation => false
        property :url,      String, :auto_validation => false
        property :code,     String, :auto_validation => false, :default => "123456"

        #
        # Validations
        #

        # this is a trivial example
        validates_format_of :doc_no, :with => lambda { |code|
          code =~ /\AA\d{4}\z/ || code =~ /\A[B-Z]\d{6}X12\z/
        }

        validates_format_of :email, :as => :email_address
        validates_format_of :url, :as => :url, :allow_nil => false, :allow_blank => false

        validates_format_of :username, :with => /[a-z]/, :message => 'Username must have at least one letter', :allow_nil => true
        validates_format_of :code,     :with => /\d{5,6}/, :message => 'Code format is invalid'
      end
    end # Fixtures
  end # Validations
end # DataMapper

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dm-validations-1.1.0 spec/fixtures/bill_of_landing.rb
dm-validations-1.1.0.rc3 spec/fixtures/bill_of_landing.rb
dm-validations-1.1.0.rc2 spec/fixtures/bill_of_landing.rb
dm-validations-1.1.0.rc1 spec/fixtures/bill_of_landing.rb
dm-validations-1.0.2 spec/fixtures/bill_of_landing.rb
dm-validations-1.0.1 spec/fixtures/bill_of_landing.rb
dm-validations-1.0.0 spec/fixtures/bill_of_landing.rb
dm-validations-1.0.0.rc3 spec/fixtures/bill_of_landing.rb
dm-validations-1.0.0.rc2 spec/fixtures/bill_of_landing.rb
dm-validations-1.0.0.rc1 spec/fixtures/bill_of_landing.rb