Module: Nokotime::Validator::ProjectSchema
- Defined in:
- lib/nokotime/validator/project_schema.rb
Constant Summary collapse
- PROJECT_SCHEMA =
Dry::Validation.Schema do configure do config.namespace = :project config. = File.join(__dir__, "validation.yml") predicates(RestrictedHash) def allowed_keys %i( name project_group_ids billing_increment enabled billable per_page ) end def valid_increment %w(1 5 6 10 15) end def valid_increment?(, values) values.split(",").all? do |value| valid_increment.include?(value) end end end restricted_hash?(allowed_keys) do optional(:name).filled :str? optional(:project_group_ids).filled :str? optional(:billing_increment).filled :str? optional(:billing_increment).filled(valid_increment?: {}) optional(:enabled).filled :bool? optional(:billable).filled :bool? optional(:per_page).filled :int? end end
Class Method Summary collapse
Class Method Details
.validate(attributes) ⇒ Object
44 45 46 |
# File 'lib/nokotime/validator/project_schema.rb', line 44 def self.validate(attributes) PROJECT_SCHEMA.call(attributes) end |