Skip to main content
100%

Gist 231720

✓ Published0🌍 Public
XXXX
Last edited Nov 11, 2009
Created on Nov 11, 2009

This example demonstrates a bug in DataMapper validation where a boolean field incorrectly accepts `false` as valid. The code defines a `Foo` resource with an `age_check` Boolean property and a `validates_is_accepted` rule that should reject unaccepted values. Using DataMapper’s `setup` and `auto_migrate!` with an in-memory SQLite database, it creates a new record with `age_check` set to `false` and calls `valid?`, which returns `true` instead of the expected `false`. The snippet highlights the validation’s failure specifically for Boolean types, noting that changing the property to a String resolves the issue.

AI-generated description

Similar vizzes