### Home Classes Methods

### In Files

- lib/sequel/plugins/validation_class_methods.rb

### Namespace

- CLASS Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator

### Methods

- #has_validations?
- #skip_superclass_validations
- #skip_superclass_validations?
- #validate
- #validates
- #validates_acceptance_of
- #validates_confirmation_of
- #validates_each
- #validates_format_of
- #validates_inclusion_of
- #validates_length_of
- #validates_not_string
- #validates_numericality_of
- #validates_presence_of
- #validates_schema_type
- #validates_uniqueness_of

### Files

- CHANGELOG
- MIT-LICENSE
- README.rdoc
- active_record.rdoc
- advanced_associations.rdoc
- association_basics.rdoc
- bin_sequel.rdoc
- cheat_sheet.rdoc
- code_order.rdoc
- core_extensions.rdoc
- dataset_basics.rdoc
- dataset_filtering.rdoc
- mass_assignment.rdoc
- migration.rdoc
- model_hooks.rdoc
- object_model.rdoc
- opening_databases.rdoc
- postgresql.rdoc
- prepared_statements.rdoc
- querying.rdoc
- reflection.rdoc
- 1.0.txt
- 1.1.txt
- 1.3.txt
- 1.4.0.txt
- 1.5.0.txt
- 2.0.0.txt
- 2.1.0.txt
- 2.10.0.txt
- 2.11.0.txt
- 2.12.0.txt
- 2.2.0.txt
- 2.3.0.txt
- 2.4.0.txt
- 2.5.0.txt
- 2.6.0.txt
- 2.7.0.txt
- 2.8.0.txt
- 2.9.0.txt
- 3.0.0.txt
- 3.1.0.txt
- 3.10.0.txt
- 3.11.0.txt
- 3.12.0.txt
- 3.13.0.txt
- 3.14.0.txt
- 3.15.0.txt
- 3.16.0.txt
- 3.17.0.txt
- 3.18.0.txt
- 3.19.0.txt
- 3.2.0.txt
- 3.20.0.txt
- 3.21.0.txt
- 3.22.0.txt
- 3.23.0.txt
- 3.24.0.txt
- 3.25.0.txt
- 3.26.0.txt
- 3.27.0.txt
- 3.28.0.txt
- 3.29.0.txt
- 3.3.0.txt
- 3.30.0.txt
- 3.31.0.txt
- 3.32.0.txt
- 3.33.0.txt
- 3.34.0.txt
- 3.35.0.txt
- 3.36.0.txt
- 3.37.0.txt
- 3.38.0.txt
- 3.39.0.txt
- 3.4.0.txt
- 3.40.0.txt
- 3.41.0.txt
- 3.42.0.txt
- 3.43.0.txt
- 3.44.0.txt
- 3.45.0.txt
- 3.46.0.txt
- 3.47.0.txt
- 3.48.0.txt
- 3.5.0.txt
- 3.6.0.txt
- 3.7.0.txt
- 3.8.0.txt
- 3.9.0.txt
- schema_modification.rdoc
- security.rdoc
- sharding.rdoc
- sql.rdoc
- testing.rdoc
- thread_safety.rdoc
- transactions.rdoc
- validations.rdoc
- virtual_rows.rdoc

### Class/Module Index

Quicksearch

- Sequel
- Sequel::ADO
- Sequel::ADO::Access
- Sequel::ADO::Access::AdoSchema
- Sequel::ADO::Access::AdoSchema::Column
- Sequel::ADO::Access::DatabaseMethods
- Sequel::ADO::Access::Dataset
- Sequel::ADO::Database
- Sequel::ADO::Dataset
- Sequel::ADO::MSSQL
- Sequel::ADO::MSSQL::DatabaseMethods
- Sequel::ADO::MSSQL::Dataset
- Sequel::ASTTransformer
- Sequel::Access
- Sequel::Access::DatabaseMethods
- Sequel::Access::DatasetMethods
- Sequel::AdapterNotFound
- Sequel::Amalgalite
- Sequel::Amalgalite::Database
- Sequel::Amalgalite::Dataset
- Sequel::Amalgalite::SequelTypeMap
- Sequel::ArbitraryServers
- Sequel::BasicObject
- Sequel::BeforeHookFailed
- Sequel::CheckConstraintViolation
- Sequel::ColumnsIntrospection
- Sequel::ConnectionPool
- Sequel::ConnectionPool::ClassMethods
- Sequel::ConnectionValidator
- Sequel::ConnectionValidator::Retry
- Sequel::ConstraintValidations
- Sequel::ConstraintValidations::AlterTableGeneratorMethods
- Sequel::ConstraintValidations::CreateTableGeneratorMethods
- Sequel::ConstraintValidations::Generator
- Sequel::ConstraintViolation
- Sequel::CoreRefinements
- Sequel::Cubrid
- Sequel::Cubrid::Database
- Sequel::Cubrid::DatabaseMethods
- Sequel::Cubrid::Dataset
- Sequel::Cubrid::DatasetMethods
- Sequel::DB2
- Sequel::DB2::DB2Error
- Sequel::DB2::Database
- Sequel::DB2::DatabaseMethods
- Sequel::DB2::Dataset
- Sequel::DB2::DatasetMethods
- Sequel::DBI
- Sequel::DBI::Database
- Sequel::DBI::Dataset
- Sequel::DataObjects
- Sequel::DataObjects::Database
- Sequel::DataObjects::Dataset
- Sequel::DataObjects::MySQL
- Sequel::DataObjects::MySQL::DatabaseMethods
- Sequel::DataObjects::MySQL::Dataset
- Sequel::DataObjects::Postgres
- Sequel::DataObjects::Postgres::DatabaseMethods
- Sequel::DataObjects::SQLite
- Sequel::DataObjects::SQLite::DatabaseMethods
- Sequel::Database
- Sequel::Database::DatasetClass
- Sequel::Database::ResetIdentifierMangling
- Sequel::Database::SplitAlterTable
- Sequel::DatabaseConnectionError
- Sequel::DatabaseDisconnectError
- Sequel::DatabaseError
- Sequel::DatabaseQuery
- Sequel::Dataset
- Sequel::Dataset::ArgumentMapper
- Sequel::Dataset::DeprecateModifyHash
- Sequel::Dataset::NullDataset
- Sequel::Dataset::Nullifiable
- Sequel::Dataset::Pagination
- Sequel::Dataset::PreparedStatementMethods
- Sequel::Dataset::Query
- Sequel::Dataset::SplitArrayNil
- Sequel::Dataset::StoredProcedureMethods
- Sequel::Dataset::StoredProcedures
- Sequel::Dataset::UnnumberedArgumentMapper
- Sequel::DatasetPagination
- Sequel::DatasetPrinter
- Sequel::DatasetQuery
- Sequel::Deprecation
- Sequel::EmptyArrayIgnoreNulls
- Sequel::EmulateOffsetWithReverseAndCount
- Sequel::EmulateOffsetWithRowNumber
- Sequel::Error
- Sequel::Error::AdapterNotFound
- Sequel::Error::InvalidOperation
- Sequel::Error::InvalidValue
- Sequel::Error::PoolTimeoutError
- Sequel::Error::Rollback
- Sequel::EvalInspect
- Sequel::FilterHaving
- Sequel::Firebird
- Sequel::Firebird::Database
- Sequel::Firebird::DatabaseMethods
- Sequel::Firebird::Dataset
- Sequel::Firebird::DatasetMethods
- Sequel::ForeignKeyConstraintViolation
- Sequel::GraphEach
- Sequel::HashAliases
- Sequel::HookFailed
- Sequel::IBMDB
- Sequel::IBMDB::Connection
- Sequel::IBMDB::Connection::Error
- Sequel::IBMDB::Database
- Sequel::IBMDB::Dataset
- Sequel::IBMDB::Dataset::CallableStatementMethods
- Sequel::IBMDB::Dataset::PreparedStatementMethods
- Sequel::IBMDB::Statement
- Sequel::Inflections
- Sequel::Informix
- Sequel::Informix::Database
- Sequel::Informix::DatabaseMethods
- Sequel::Informix::Dataset
- Sequel::Informix::DatasetMethods
- Sequel::IntegerMigrator
- Sequel::InvalidOperation
- Sequel::InvalidValue
- Sequel::JDBC
- Sequel::JDBC::AS400
- Sequel::JDBC::AS400::DatabaseMethods
- Sequel::JDBC::AS400::Dataset
- Sequel::JDBC::Cubrid
- Sequel::JDBC::Cubrid::DatabaseMethods
- Sequel::JDBC::DB2
- Sequel::JDBC::DB2::DatabaseMethods
- Sequel::JDBC::DB2::Dataset
- Sequel::JDBC::Database
- Sequel::JDBC::Dataset
- Sequel::JDBC::Dataset::PreparedStatementMethods
- Sequel::JDBC::Dataset::StoredProcedureMethods
- Sequel::JDBC::Dataset::TYPE_TRANSLATOR
- Sequel::JDBC::Derby
- Sequel::JDBC::Derby::DatabaseMethods
- Sequel::JDBC::Derby::Dataset
- Sequel::JDBC::Firebird
- Sequel::JDBC::Firebird::DatabaseMethods
- Sequel::JDBC::H2
- Sequel::JDBC::H2::DatabaseMethods
- Sequel::JDBC::H2::Dataset
- Sequel::JDBC::HSQLDB
- Sequel::JDBC::HSQLDB::DatabaseMethods
- Sequel::JDBC::HSQLDB::Dataset
- Sequel::JDBC::Informix
- Sequel::JDBC::Informix::DatabaseMethods
- Sequel::JDBC::JTDS
- Sequel::JDBC::JTDS::DatabaseMethods
- Sequel::JDBC::JTDS::Dataset
- Sequel::JDBC::JavaLang
- Sequel::JDBC::JavaSQL
- Sequel::JDBC::JavaxNaming
- Sequel::JDBC::MSSQL
- Sequel::JDBC::MSSQL::DatabaseMethods
- Sequel::JDBC::MySQL
- Sequel::JDBC::MySQL::DatabaseMethods
- Sequel::JDBC::Oracle
- Sequel::JDBC::Oracle::DatabaseMethods
- Sequel::JDBC::Oracle::Dataset
- Sequel::JDBC::Postgres
- Sequel::JDBC::Postgres::DatabaseMethods
- Sequel::JDBC::Postgres::Dataset
- Sequel::JDBC::Postgres::Dataset::PGArrayConverter
- Sequel::JDBC::Progress
- Sequel::JDBC::Progress::DatabaseMethods
- Sequel::JDBC::SQLServer
- Sequel::JDBC::SQLServer::DatabaseMethods
- Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods
- Sequel::JDBC::SQLite
- Sequel::JDBC::SQLite::DatabaseMethods
- Sequel::JDBC::Transactions
- Sequel::LiteralString
- Sequel::LooserTypecasting
- Sequel::MSSQL
- Sequel::MSSQL::DatabaseMethods
- Sequel::MSSQL::DatasetMethods
- Sequel::Metaprogramming
- Sequel::Migration
- Sequel::MigrationAlterTableReverser
- Sequel::MigrationDSL
- Sequel::MigrationReverser
- Sequel::Migrator
- Sequel::Migrator::Error
- Sequel::Migrator::NotCurrentError
- Sequel::Mock
- Sequel::Mock::Connection
- Sequel::Mock::Database
- Sequel::Mock::Dataset
- Sequel::Model
- Sequel::Model::Associations
- Sequel::Model::Associations::AssociationDatasetMethods
- Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ClassMethods
- Sequel::Model::Associations::DatasetMethods
- Sequel::Model::Associations::EagerGraphLoader
- Sequel::Model::Associations::InstanceMethods
- Sequel::Model::Associations::ManyToManyAssociationReflection
- Sequel::Model::Associations::ManyToOneAssociationReflection
- Sequel::Model::Associations::OneToManyAssociationReflection
- Sequel::Model::Associations::OneToOneAssociationReflection
- Sequel::Model::ClassMethods
- Sequel::Model::DatasetMethods
- Sequel::Model::DatasetModule
- Sequel::Model::Errors
- Sequel::Model::InstanceMethods
- Sequel::MySQL
- Sequel::MySQL::Database
- Sequel::MySQL::DatabaseMethods
- Sequel::MySQL::Dataset
- Sequel::MySQL::DatasetMethods
- Sequel::MySQL::PreparedStatements
- Sequel::MySQL::PreparedStatements::DatabaseMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods::CallableStatementMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods::PreparedStatementMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods::StoredProcedureMethods
- Sequel::Mysql2
- Sequel::Mysql2::Database
- Sequel::Mysql2::Dataset
- Sequel::NamedTimezones
- Sequel::NamedTimezones::DatabaseMethods
- Sequel::NoExistingObject
- Sequel::NoMatchingRow
- Sequel::NotImplemented
- Sequel::NotNullConstraintViolation
- Sequel::ODBC
- Sequel::ODBC::Database
- Sequel::ODBC::Dataset
- Sequel::ODBC::MSSQL
- Sequel::ODBC::MSSQL::DatabaseMethods
- Sequel::ODBC::MSSQL::Dataset
- Sequel::OpenBase
- Sequel::OpenBase::Database
- Sequel::OpenBase::Dataset
- Sequel::Oracle
- Sequel::Oracle::Database
- Sequel::Oracle::DatabaseMethods
- Sequel::Oracle::Dataset
- Sequel::Oracle::Dataset::ArgumentMapper
- Sequel::Oracle::Dataset::BindArgumentMethods
- Sequel::Oracle::Dataset::PreparedStatementMethods
- Sequel::Oracle::DatasetMethods
- Sequel::Plugins
- Sequel::Plugins::ActiveModel
- Sequel::Plugins::ActiveModel::ClassMethods
- Sequel::Plugins::ActiveModel::Errors
- Sequel::Plugins::ActiveModel::InstanceMethods
- Sequel::Plugins::AfterInitialize
- Sequel::Plugins::AfterInitialize::ClassMethods
- Sequel::Plugins::AfterInitialize::InstanceMethods
- Sequel::Plugins::AssociationAutoreloading
- Sequel::Plugins::AssociationAutoreloading::ClassMethods
- Sequel::Plugins::AssociationAutoreloading::InstanceMethods
- Sequel::Plugins::AssociationDependencies
- Sequel::Plugins::AssociationDependencies::ClassMethods
- Sequel::Plugins::AssociationDependencies::InstanceMethods
- Sequel::Plugins::AssociationPks
- Sequel::Plugins::AssociationPks::ClassMethods
- Sequel::Plugins::AssociationPks::InstanceMethods
- Sequel::Plugins::AssociationProxies
- Sequel::Plugins::AssociationProxies::AssociationProxy
- Sequel::Plugins::AssociationProxies::ClassMethods
- Sequel::Plugins::AutoValidations
- Sequel::Plugins::AutoValidations::ClassMethods
- Sequel::Plugins::AutoValidations::InstanceMethods
- Sequel::Plugins::BlacklistSecurity
- Sequel::Plugins::BlacklistSecurity::ClassMethods
- Sequel::Plugins::BlacklistSecurity::InstanceMethods
- Sequel::Plugins::BooleanReaders
- Sequel::Plugins::BooleanReaders::ClassMethods
- Sequel::Plugins::Caching
- Sequel::Plugins::Caching::ClassMethods
- Sequel::Plugins::Caching::InstanceMethods
- Sequel::Plugins::ClassTableInheritance
- Sequel::Plugins::ClassTableInheritance::ClassMethods
- Sequel::Plugins::ClassTableInheritance::InstanceMethods
- Sequel::Plugins::Composition
- Sequel::Plugins::Composition::ClassMethods
- Sequel::Plugins::Composition::InstanceMethods
- Sequel::Plugins::ConstraintValidations
- Sequel::Plugins::ConstraintValidations::ClassMethods
- Sequel::Plugins::ConstraintValidations::DatabaseMethods
- Sequel::Plugins::ConstraintValidations::InstanceMethods
- Sequel::Plugins::DatasetAssociations
- Sequel::Plugins::DatasetAssociations::ClassMethods
- Sequel::Plugins::DatasetAssociations::DatasetMethods
- Sequel::Plugins::DefaultsSetter
- Sequel::Plugins::DefaultsSetter::ClassMethods
- Sequel::Plugins::DefaultsSetter::InstanceMethods
- Sequel::Plugins::Dirty
- Sequel::Plugins::Dirty::InstanceMethods
- Sequel::Plugins::EagerEach
- Sequel::Plugins::EagerEach::DatasetMethods
- Sequel::Plugins::ErrorSplitter
- Sequel::Plugins::ErrorSplitter::InstanceMethods
- Sequel::Plugins::ForceEncoding
- Sequel::Plugins::ForceEncoding::ClassMethods
- Sequel::Plugins::ForceEncoding::InstanceMethods
- Sequel::Plugins::HookClassMethods
- Sequel::Plugins::HookClassMethods::ClassMethods
- Sequel::Plugins::HookClassMethods::InstanceMethods
- Sequel::Plugins::IdentityMap
- Sequel::Plugins::IdentityMap::ClassMethods
- Sequel::Plugins::IdentityMap::InstanceMethods
- Sequel::Plugins::InputTransformer
- Sequel::Plugins::InputTransformer::ClassMethods
- Sequel::Plugins::InputTransformer::InstanceMethods
- Sequel::Plugins::InstanceFilters
- Sequel::Plugins::InstanceFilters::InstanceMethods
- Sequel::Plugins::InstanceHooks
- Sequel::Plugins::InstanceHooks::InstanceMethods
- Sequel::Plugins::JsonSerializer
- Sequel::Plugins::JsonSerializer::ClassMethods
- Sequel::Plugins::JsonSerializer::DatasetMethods
- Sequel::Plugins::JsonSerializer::InstanceMethods
- Sequel::Plugins::JsonSerializer::Literal
- Sequel::Plugins::LazyAttributes
- Sequel::Plugins::LazyAttributes::ClassMethods
- Sequel::Plugins::LazyAttributes::InstanceMethods
- Sequel::Plugins::List
- Sequel::Plugins::List::ClassMethods
- Sequel::Plugins::List::InstanceMethods
- Sequel::Plugins::ManyThroughMany
- Sequel::Plugins::ManyThroughMany::ClassMethods
- Sequel::Plugins::ManyThroughMany::DatasetMethods
- Sequel::Plugins::ManyThroughMany::ManyThroughManyAssociationReflection
- Sequel::Plugins::ManyToOnePkLookup
- Sequel::Plugins::ManyToOnePkLookup::ClassMethods
- Sequel::Plugins::ManyToOnePkLookup::InstanceMethods
- Sequel::Plugins::NestedAttributes
- Sequel::Plugins::NestedAttributes::ClassMethods
- Sequel::Plugins::NestedAttributes::InstanceMethods
- Sequel::Plugins::OptimisticLocking
- Sequel::Plugins::OptimisticLocking::ClassMethods
- Sequel::Plugins::OptimisticLocking::InstanceMethods
- Sequel::Plugins::PgRow
- Sequel::Plugins::PgRow::ClassMethods
- Sequel::Plugins::PgRow::DatabaseMethods
- Sequel::Plugins::PgRow::InstanceMethods
- Sequel::Plugins::PgTypecastOnLoad
- Sequel::Plugins::PgTypecastOnLoad::ClassMethods
- Sequel::Plugins::PgTypecastOnLoad::InstanceMethods
- Sequel::Plugins::PreparedStatements
- Sequel::Plugins::PreparedStatements::ClassMethods
- Sequel::Plugins::PreparedStatements::InstanceMethods
- Sequel::Plugins::PreparedStatementsAssociations
- Sequel::Plugins::PreparedStatementsAssociations::ClassMethods
- Sequel::Plugins::PreparedStatementsAssociations::InstanceMethods
- Sequel::Plugins::PreparedStatementsSafe
- Sequel::Plugins::PreparedStatementsSafe::ClassMethods
- Sequel::Plugins::PreparedStatementsSafe::InstanceMethods
- Sequel::Plugins::PreparedStatementsWithPk
- Sequel::Plugins::PreparedStatementsWithPk::ClassMethods
- Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods
- Sequel::Plugins::RcteTree
- Sequel::Plugins::Schema
- Sequel::Plugins::Schema::ClassMethods
- Sequel::Plugins::Scissors
- Sequel::Plugins::Scissors::ClassMethods
- Sequel::Plugins::Serialization
- Sequel::Plugins::Serialization::ClassMethods
- Sequel::Plugins::Serialization::InstanceMethods
- Sequel::Plugins::SerializationModificationDetection
- Sequel::Plugins::SerializationModificationDetection::InstanceMethods
- Sequel::Plugins::Sharding
- Sequel::Plugins::Sharding::ClassMethods
- Sequel::Plugins::Sharding::DatasetMethods
- Sequel::Plugins::Sharding::InstanceMethods
- Sequel::Plugins::SingleTableInheritance
- Sequel::Plugins::SingleTableInheritance::ClassMethods
- Sequel::Plugins::SingleTableInheritance::InstanceMethods
- Sequel::Plugins::SkipCreateRefresh
- Sequel::Plugins::SkipCreateRefresh::InstanceMethods
- Sequel::Plugins::StaticCache
- Sequel::Plugins::StaticCache::ClassMethods
- Sequel::Plugins::StringStripper
- Sequel::Plugins::StringStripper::ClassMethods
- Sequel::Plugins::Subclasses
- Sequel::Plugins::Subclasses::ClassMethods
- Sequel::Plugins::TacticalEagerLoading
- Sequel::Plugins::TacticalEagerLoading::DatasetMethods
- Sequel::Plugins::TacticalEagerLoading::InstanceMethods
- Sequel::Plugins::Timestamps
- Sequel::Plugins::Timestamps::ClassMethods
- Sequel::Plugins::Timestamps::InstanceMethods
- Sequel::Plugins::Touch
- Sequel::Plugins::Touch::ClassMethods
- Sequel::Plugins::Touch::InstanceMethods
- Sequel::Plugins::Tree
- Sequel::Plugins::Tree::ClassMethods
- Sequel::Plugins::Tree::InstanceMethods
- Sequel::Plugins::Tree::SingleRoot
- Sequel::Plugins::Tree::SingleRoot::ClassMethods
- Sequel::Plugins::Tree::SingleRoot::InstanceMethods
- Sequel::Plugins::Tree::TreeMultipleRootError
- Sequel::Plugins::TypecastOnLoad
- Sequel::Plugins::TypecastOnLoad::ClassMethods
- Sequel::Plugins::TypecastOnLoad::InstanceMethods
- Sequel::Plugins::UnlimitedUpdate
- Sequel::Plugins::UnlimitedUpdate::InstanceMethods
- Sequel::Plugins::UpdatePrimaryKey
- Sequel::Plugins::UpdatePrimaryKey::InstanceMethods
- Sequel::Plugins::ValidationClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator
- Sequel::Plugins::ValidationClassMethods::InstanceMethods
- Sequel::Plugins::ValidationHelpers
- Sequel::Plugins::ValidationHelpers::InstanceMethods
- Sequel::Plugins::XmlSerializer
- Sequel::Plugins::XmlSerializer::ClassMethods
- Sequel::Plugins::XmlSerializer::DatasetMethods
- Sequel::Plugins::XmlSerializer::InstanceMethods
- Sequel::PoolTimeout
- Sequel::Postgres
- Sequel::Postgres::Adapter
- Sequel::Postgres::AlterTableGenerator
- Sequel::Postgres::ArrayOp
- Sequel::Postgres::ArrayOpMethods
- Sequel::Postgres::AutoParameterize
- Sequel::Postgres::AutoParameterize::DatabaseMethods
- Sequel::Postgres::AutoParameterize::DatasetMethods
- Sequel::Postgres::AutoParameterize::StringWithArray
- Sequel::Postgres::CreateTableGenerator
- Sequel::Postgres::Database
- Sequel::Postgres::DatabaseMethods
- Sequel::Postgres::Dataset
- Sequel::Postgres::Dataset::ArgumentMapper
- Sequel::Postgres::Dataset::BindArgumentMethods
- Sequel::Postgres::Dataset::PreparedStatementMethods
- Sequel::Postgres::DatasetMethods
- Sequel::Postgres::DatasetMethods::PreparedStatementMethods
- Sequel::Postgres::ExclusionConstraintViolation
- Sequel::Postgres::HStore
- Sequel::Postgres::HStore::DatabaseMethods
- Sequel::Postgres::HStore::Parser
- Sequel::Postgres::HStoreOp
- Sequel::Postgres::HStoreOpMethods
- Sequel::Postgres::InetDatabaseMethods
- Sequel::Postgres::InetDatasetMethods
- Sequel::Postgres::IntervalDatabaseMethods
- Sequel::Postgres::IntervalDatabaseMethods::Parser
- Sequel::Postgres::IntervalDatasetMethods
- Sequel::Postgres::JSONArray
- Sequel::Postgres::JSONDatabaseMethods
- Sequel::Postgres::JSONHash
- Sequel::Postgres::PGArray
- Sequel::Postgres::PGArray::Creator
- Sequel::Postgres::PGArray::DatabaseMethods
- Sequel::Postgres::PGArray::JSONCreator
- Sequel::Postgres::PGArray::Parser
- Sequel::Postgres::PGRange
- Sequel::Postgres::PGRange::DatabaseMethods
- Sequel::Postgres::PGRange::DatasetMethods
- Sequel::Postgres::PGRange::Parser
- Sequel::Postgres::PGRow
- Sequel::Postgres::PGRow::ArrayRow
- Sequel::Postgres::PGRow::DatabaseMethods
- Sequel::Postgres::PGRow::HashRow
- Sequel::Postgres::PGRow::Parser
- Sequel::Postgres::PGRow::Splitter
- Sequel::Postgres::PGRowOp
- Sequel::Postgres::PGRowOp::ExpressionMethods
- Sequel::Postgres::RangeOp
- Sequel::Postgres::RangeOpMethods
- Sequel::Postgres::StatementCache
- Sequel::Postgres::StatementCache::AdapterMethods
- Sequel::Postgres::StatementCache::DatabaseMethods
- Sequel::Postgres::StatementCache::Statement
- Sequel::Postgres::StatementCache::StatementCache
- Sequel::PrettyTable
- Sequel::Progress
- Sequel::Progress::DatabaseMethods
- Sequel::Progress::DatasetMethods
- Sequel::Qualifier
- Sequel::QueryLiterals
- Sequel::Rollback
- Sequel::SQL
- Sequel::SQL::AliasMethods
- Sequel::SQL::AliasedExpression
- Sequel::SQL::BitwiseMethods
- Sequel::SQL::Blob
- Sequel::SQL::BooleanConstant
- Sequel::SQL::BooleanExpression
- Sequel::SQL::BooleanMethods
- Sequel::SQL::Builders
- Sequel::SQL::CaseExpression
- Sequel::SQL::Cast
- Sequel::SQL::CastMethods
- Sequel::SQL::ColumnAll
- Sequel::SQL::ComplexExpression
- Sequel::SQL::ComplexExpressionMethods
- Sequel::SQL::Constant
- Sequel::SQL::Constants
- Sequel::SQL::DateAdd
- Sequel::SQL::DateAdd::DatasetMethods
- Sequel::SQL::DelayedEvaluation
- Sequel::SQL::EmulatedFunction
- Sequel::SQL::Expression
- Sequel::SQL::Function
- Sequel::SQL::GenericExpression
- Sequel::SQL::Identifier
- Sequel::SQL::InequalityMethods
- Sequel::SQL::JoinClause
- Sequel::SQL::JoinOnClause
- Sequel::SQL::JoinUsingClause
- Sequel::SQL::NegativeBooleanConstant
- Sequel::SQL::NoBooleanInputMethods
- Sequel::SQL::NumericExpression
- Sequel::SQL::NumericMethods
- Sequel::SQL::OperatorBuilders
- Sequel::SQL::OrderMethods
- Sequel::SQL::OrderedExpression
- Sequel::SQL::PlaceholderLiteralString
- Sequel::SQL::QualifiedIdentifier
- Sequel::SQL::QualifyingMethods
- Sequel::SQL::SQLArray
- Sequel::SQL::StringConcatenationMethods
- Sequel::SQL::StringExpression
- Sequel::SQL::StringMethods
- Sequel::SQL::Subscript
- Sequel::SQL::SubscriptMethods
- Sequel::SQL::ValueList
- Sequel::SQL::VirtualRow
- Sequel::SQL::Window
- Sequel::SQL::WindowFunction
- Sequel::SQL::Wrapper
- Sequel::SQLTime
- Sequel::SQLite
- Sequel::SQLite::Database
- Sequel::SQLite::DatabaseMethods
- Sequel::SQLite::Dataset
- Sequel::SQLite::Dataset::ArgumentMapper
- Sequel::SQLite::Dataset::BindArgumentMethods
- Sequel::SQLite::Dataset::PreparedStatementMethods
- Sequel::SQLite::DatasetMethods
- Sequel::Schema
- Sequel::Schema::AlterTableGenerator
- Sequel::Schema::CreateTableGenerator
- Sequel::Schema::Generator
- Sequel::SchemaCaching
- Sequel::SchemaDumper
- Sequel::SelectRemove
- Sequel::Sequel3DatasetMethods
- Sequel::SerializationFailure
- Sequel::ServerBlock
- Sequel::SetOverrides
- Sequel::ShardedSingleConnectionPool
- Sequel::ShardedThreadedConnectionPool
- Sequel::SimpleMigration
- Sequel::SingleConnectionPool
- Sequel::Swift
- Sequel::Swift::Database
- Sequel::Swift::Dataset
- Sequel::Swift::MySQL
- Sequel::Swift::MySQL::DatabaseMethods
- Sequel::Swift::MySQL::Dataset
- Sequel::Swift::Postgres
- Sequel::Swift::Postgres::DatabaseMethods
- Sequel::Swift::SQLite
- Sequel::Swift::SQLite::DatabaseMethods
- Sequel::Swift::SQLite::Dataset
- Sequel::ThreadLocalTimezones
- Sequel::ThreadedConnectionPool
- Sequel::ThreadedServerBlock
- Sequel::TimestampMigrator
- Sequel::Timezones
- Sequel::TinyTDS
- Sequel::TinyTDS::Database
- Sequel::TinyTDS::Dataset
- Sequel::TinyTDS::Dataset::ArgumentMapper
- Sequel::TinyTDS::Dataset::PreparedStatementMethods
- Sequel::ToDot
- Sequel::ToDot::DatasetMethods
- Sequel::UnbindDuplicate
- Sequel::Unbinder
- Sequel::UndefinedAssociation
- Sequel::UniqueConstraintViolation
- Sequel::UnthreadedServerBlock
- Sequel::ValidationFailed
- String
- String::Inflections
- Array
- FalseClass
- Hash
- NilClass
- Numeric
- Object
- PGconn
- PGresult
- Range
- Symbol
- TrueClass

No matching classes.

# Sequel::Plugins::ValidationClassMethods::ClassMethods

### Attributes

validation_reflections[R]

A hash of validation reflections for this model class. Keys are column symbols, values are an array of two element arrays, with the first element being the validation type symbol and the second being a hash of validation options.

validations[R]

A hash of validations for this model class. Keys are column symbols, values are arrays of validation procs.

### Public Instance Methods

has_validations?() click to toggle source

Returns true if validations are defined.

    # File lib/sequel/plugins/validation_class_methods.rb, line 61
    def has_validations?
      !validations.empty?
    end

skip_superclass_validations() click to toggle source

Instructs the model to skip validations defined in superclasses

    # File lib/sequel/plugins/validation_class_methods.rb, line 68
    def skip_superclass_validations
      superclass.validations.each do |att, procs|
        if ps = @validations[att]
          @validations[att] -= procs
        end
      end
      @skip_superclass_validations = true
    end

skip_superclass_validations?() click to toggle source

Instructs the model to skip validations defined in superclasses

    # File lib/sequel/plugins/validation_class_methods.rb, line 78
    def skip_superclass_validations?
      @skip_superclass_validations
    end

validate(o) click to toggle source

Validates the given instance.

    # File lib/sequel/plugins/validation_class_methods.rb, line 102
    def validate(o)
      validations.each do |att, procs|
        v = case att
        when Array
          att.collect{|a| o.send(a)}
        else
          o.send(att)
        end
        procs.each {|tag, p| p.call(o, att, v)}
      end
    end

validates(&block) click to toggle source

Defines validations by converting a longhand block into a series of shorthand definitions. For example:

    class MyClass < Sequel::Model
      validates do
        length_of :name, :minimum => 6
        length_of :password, :minimum => 8
      end
    end

is equivalent to:

    class MyClass < Sequel::Model
      validates_length_of :name, :minimum => 6
      validates_length_of :password, :minimum => 8
    end

    # File lib/sequel/plugins/validation_class_methods.rb, line 97
    def validates(&block)
      Generator.new(self, &block)
    end

validates_acceptance_of(*atts) click to toggle source

Validates acceptance of an attribute. Just checks that the value is equal to the :accept option. This method is unique in that :allow_nil is assumed to be true instead of false.

Possible Options:

- :accept - The value required for the object to be valid (default: '1')

- :message - The message to use (default: 'is not accepted')

    # File lib/sequel/plugins/validation_class_methods.rb, line 121
    def validates_acceptance_of(*atts)
      opts = {
        :message => 'is not accepted',
        :allow_nil => true,
        :accept => '1',
        :tag => :acceptance,
      }.merge!(extract_options!(atts))
      reflect_validation(:acceptance, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        o.errors.add(a, opts[:message]) unless v == opts[:accept]
      end
    end

validates_confirmation_of(*atts) click to toggle source

Validates confirmation of an attribute. Checks that the object has a _confirmation value matching the current value. For example:

    validates_confirmation_of :blah

Just makes sure that object.blah = object.blah_confirmation. Often used for passwords or email addresses on web forms.

Possible Options:

- :message - The message to use (default: 'is not confirmed')

    # File lib/sequel/plugins/validation_class_methods.rb, line 145
    def validates_confirmation_of(*atts)
      opts = {
        :message => 'is not confirmed',
        :tag => :confirmation,
      }.merge!(extract_options!(atts))
      reflect_validation(:confirmation, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        o.errors.add(a, opts[:message]) unless v == o.send(:"#{a}_confirmation")
      end
    end

validates_each(*atts, &block) click to toggle source

Adds a validation for each of the given attributes using the supplied block. The block must accept three arguments: instance, attribute and value, e.g.:

    validates_each :name, :password do |object, attribute, value|
      object.errors.add(attribute, 'is not nice') unless value.nice?
    end

Possible Options:

- :allow_blank - Whether to skip the validation if the value is blank.

- :allow_missing - Whether to skip the validation if the attribute isn't a key in the values hash. This is different from allow_nil, because Sequel only sends the attributes in the values when doing an insert or update. If the attribute is not present, Sequel doesn't specify it, so the database will use the table's default value. This is different from having an attribute in values with a value of nil, which Sequel will send as NULL. If your database table has a non NULL default, this may be a good option to use. You don't want to use allow_nil, because if the attribute is in values but has a value nil, Sequel will attempt to insert a NULL value into the database, instead of using the database's default.

- :allow_nil - Whether to skip the validation if the value is nil.

- :if - A symbol (indicating an instance_method) or proc (which is instance_evaled) skipping this validation if it returns nil or false.

- :tag - The tag to use for this validation.

    # File lib/sequel/plugins/validation_class_methods.rb, line 180
    def validates_each(*atts, &block)
      opts = extract_options!(atts)
      blk = if (i = opts[:if]) || (am = opts[:allow_missing]) || (an = opts[:allow_nil]) || (ab = opts[:allow_blank])
        proc do |o,a,v|
          next if i && !validation_if_proc(o, i)
          next if an && Array(v).all?{|x| x.nil?}
          next if ab && Array(v).all?{|x| x.blank?}
          next if am && Array(a).all?{|x| !o.values.has_key?(x)}
          block.call(o,a,v)
        end
      else
        block
      end
      tag = opts[:tag]
      atts.each do |a|
        a_vals = Sequel.synchronize{validations[a] ||= []}
        if tag && (old = a_vals.find{|x| x[0] == tag})
          old[1] = blk
        else
          a_vals << [tag, blk]
        end
      end
    end

validates_format_of(*atts) click to toggle source

Validates the format of an attribute, checking the string representation of the value against the regular expression provided by the :with option.

Possible Options:

- :message - The message to use (default: 'is invalid')

- :with - The regular expression to validate the value with (required).

    # File lib/sequel/plugins/validation_class_methods.rb, line 210
    def validates_format_of(*atts)
      opts = {
        :message => 'is invalid',
        :tag => :format,
      }.merge!(extract_options!(atts))

      unless opts[:with].is_a?(Regexp)
        raise ArgumentError, "A regular expression must be supplied as the :with option of the options hash"
      end

      reflect_validation(:format, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        o.errors.add(a, opts[:message]) unless v.to_s =~ opts[:with]
      end
    end

validates_inclusion_of(*atts) click to toggle source

Validates that an attribute is within a specified range or set of values.

Possible Options:

- :in - An array or range of values to check for validity (required)

- :message - The message to use (default: 'is not in range or set: <specified range>')

    # File lib/sequel/plugins/validation_class_methods.rb, line 344
    def validates_inclusion_of(*atts)
      opts = extract_options!(atts)
      n = opts[:in]
      unless n && (n.respond_to?(:cover?) || n.respond_to?(:include?))
        raise ArgumentError, "The :in parameter is required, and must respond to cover? or include?"
      end
      opts[:message] ||= "is not in range or set: #{n.inspect}"
      reflect_validation(:inclusion, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        o.errors.add(a, opts[:message]) unless n.send(n.respond_to?(:cover?) ? :cover? : :include?, v)
      end
    end

validates_length_of(*atts) click to toggle source

Validates the length of an attribute.

Possible Options:

- :is - The exact size required for the value to be valid (no default)

- :maximum - The maximum size allowed for the value (no default)

- :message - The message to use (no default, overrides :nil_message, :too_long, :too_short, and :wrong_length options if present)

- :minimum - The minimum size allowed for the value (no default)

- :nil_message - The message to use use if :maximum option is used and the value is nil (default: 'is not present')

- :too_long - The message to use use if it the value is too long (default: 'is too long')

- :too_short - The message to use use if it the value is too short (default: 'is too short')

- :within - The array/range that must include the size of the value for it to be valid (no default)

- :wrong_length - The message to use use if it the value is not valid (default: 'is the wrong length')

    # File lib/sequel/plugins/validation_class_methods.rb, line 240
    def validates_length_of(*atts)
      opts = {
        :nil_message  => 'is not present',
        :too_long     => 'is too long',
        :too_short    => 'is too short',
        :wrong_length => 'is the wrong length'
      }.merge!(extract_options!(atts))

      opts[:tag] ||= ([:length] + [:maximum, :minimum, :is, :within].reject{|x| !opts.include?(x)}).join('-').to_sym
      reflect_validation(:length, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        if m = opts[:maximum]
          o.errors.add(a, opts[:message] || (v ? opts[:too_long] : opts[:nil_message])) unless v && v.size <= m
        end
        if m = opts[:minimum]
          o.errors.add(a, opts[:message] || opts[:too_short]) unless v && v.size >= m
        end
        if i = opts[:is]
          o.errors.add(a, opts[:message] || opts[:wrong_length]) unless v && v.size == i
        end
        if w = opts[:within]
          o.errors.add(a, opts[:message] || opts[:wrong_length]) unless v && w.send(w.respond_to?(:cover?) ? :cover? : :include?, v.size)
        end
      end
    end

validates_not_string(*atts) click to toggle source

Validates whether an attribute is not a string. This is generally useful in conjunction with raise_on_typecast_failure = false, where you are passing in string values for non-string attributes (such as numbers and dates). If typecasting fails (invalid number or date), the value of the attribute will be a string in an invalid format, and if typecasting succeeds, the value will not be a string.

Possible Options:

- :message - The message to use (default: 'is a string' or 'is not a valid (integer|datetime|etc.)' if the type is known)

    # File lib/sequel/plugins/validation_class_methods.rb, line 276
    def validates_not_string(*atts)
      Sequel::Deprecation.deprecate('validates_not_string', "Please switch to validates_schema_type")
      opts = {
        :tag => :not_string,
      }.merge!(extract_options!(atts))
      reflect_validation(:not_string, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        if v.is_a?(String)
          unless message = opts[:message]
            message = if sch = o.db_schema[a] and typ = sch[:type]
              "is not a valid #{typ}"
            else
              "is a string"
            end
          end
          o.errors.add(a, message)
        end
      end
    end

validates_numericality_of(*atts) click to toggle source

Validates whether an attribute is a number.

Possible Options:

- :message - The message to use (default: 'is not a number')

- :only_integer - Whether only integers are valid values (default: false)

    # File lib/sequel/plugins/validation_class_methods.rb, line 302
    def validates_numericality_of(*atts)
      opts = {
        :message => 'is not a number',
        :tag => :numericality,
      }.merge!(extract_options!(atts))
      reflect_validation(:numericality, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        begin
          if opts[:only_integer]
            Kernel.Integer(v.to_s)
          else
            Kernel.Float(v.to_s)
          end
        rescue
          o.errors.add(a, opts[:message])
        end
      end
    end

validates_presence_of(*atts) click to toggle source

Validates the presence of an attribute. Requires the value not be blank, with false considered present instead of absent.

Possible Options:

- :message - The message to use (default: 'is not present')

    # File lib/sequel/plugins/validation_class_methods.rb, line 327
    def validates_presence_of(*atts)
      opts = {
        :message => 'is not present',
        :tag => :presence,
      }.merge!(extract_options!(atts))
      reflect_validation(:presence, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        o.errors.add(a, opts[:message]) if v.blank? && v != false
      end
    end

validates_schema_type(*atts) click to toggle source

Validates whether an attribute has the correct ruby type for the associated database type. This is generally useful in conjunction with raise_on_typecast_failure = false, to handle typecasting errors at validation time instead of at setter time.

Possible Options:

- :message - The message to use (default: 'is not a valid (integer|datetime|etc.)')

    # File lib/sequel/plugins/validation_class_methods.rb, line 365
    def validates_schema_type(*atts)
      opts = {
        :tag => :schema_type,
      }.merge!(extract_options!(atts))
      reflect_validation(:schema_type, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        next if v.nil? || (klass = o.send(:schema_type_class, a)).nil?
        if klass.is_a?(Array) ? !klass.any?{|kls| v.is_a?(kls)} : !v.is_a?(klass)
          message = opts[:message] || "is not a valid #{Array(klass).join(" or ").downcase}"
          o.errors.add(a, message)
        end
      end
    end

validates_uniqueness_of(*atts) click to toggle source

Validates only if the fields in the model (specified by atts) are unique in the database. Pass an array of fields instead of multiple fields to specify that the combination of fields must be unique, instead of that each field should have a unique value.

This means that the code:

    validates_uniqueness_of([:column1, :column2])

validates the grouping of column1 and column2 while

    validates_uniqueness_of(:column1, :column2)

validates them separately.

You should also add a unique index in the database, as this suffers from a fairly obvious race condition.

Possible Options:

- :message - The message to use (default: 'is already taken')

    # File lib/sequel/plugins/validation_class_methods.rb, line 396
    def validates_uniqueness_of(*atts)
      opts = {
        :message => 'is already taken',
        :tag => :uniqueness,
      }.merge!(extract_options!(atts))

      reflect_validation(:uniqueness, opts, atts)
      atts << opts
      validates_each(*atts) do |o, a, v|
        error_field = a
        a = Array(a)
        v = Array(v)
        next if v.empty? || !v.all?
        ds = o.class.filter(a.zip(v))
        num_dups = ds.count
        allow = if num_dups == 0
          # No unique value in the database
          true
        elsif num_dups > 1
          # Multiple "unique" values in the database!!
          # Someone didn't add a unique index
          false
        elsif o.new?
          # New record, but unique value already exists in the database
          false
        elsif ds.first === o
          # Unique value exists in database, but for the same record, so the update won't cause a duplicate record
          true
        else
          false
        end
        o.errors.add(error_field, opts[:message]) unless allow
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.