def validate(&block)
      validator = block

      unless value.nil?
        error = validator.call(value)
        raise ValidationError, error if error
      end

      @validator = block
    end
def validate(&block)
      validator = block

      unless value.nil?
        error = validator.call(value)
        raise ValidationError, error if error
      end

      @validator = block
    end
Declares a block to be used to validate the value of an attribute whenever it's set.
 Validation blocks should return any object to indicate an error, or +nil+/+false+ if
 validation passed.
 @yield The code that performs validation.
 @return [void]