Leo Steen 2010 Dry Creek Valley Chenin Blanc Saini Farms

2010 Leo Steen Chenin BlancThis has been one of my favorite wines for a while now, and the 2010 is another excellent effort.

Chenin blanc is perhaps most famously associated with Loire Valley, France. Some of my favorite wines from the Loire Valley come from Vouvray. I am attracted to the natural high acidity of chenin blanc. When that slight sweetness is balanced with the acidity you end up with a very refreshing glass of wine. Chenin blanc does not have a very good reputation in the United States. For the most part, chenin blanc in the United States has been grown in regions that are too hot, and it has been mostly made into simple sweet wines aimed at the mass market.

Thanks to Leo Steen, we have a great example of what can be achieved with Chenin Blanc in California. First off, this wine is fermented dry, unlike many other chenin blancs (Note: I do not think that chenin blanc must be dry to be good, as mentioned above I find many Vouvray’s to excellent wines as well). That gives it a somewhat Alsatian like minerality and crispness. I also taste slightly baked pear flavors, with a hint of pie spices that start out round on the palate, followed by a nice crisp finish that leaves citrus notes lingering on.

If you know of any other good examples of chenin blanc, post a comment and let us know about them. I imagine that there must be some good efforts coming out of Oregon and Washington as well?

Leo Steen Chenin Blanc retails for about $16-18 and there were in 2010 there were 408 cases made. For more information on Leo Steen’s wines visit the website: www.leosteenwines.com

Posted in Wine | Leave a comment

Sorelle Bronca Prosecco D.O.C. di Valdobbiadene Spumante Extra Dry

Sorelle Bronca ProseccoThis sparkling wine is a steal, about $17 retail. I think most people forget about prosecco, and there are plenty of forgettable efforts, however, Sorelle Bronca hit the mark. This wine is not too sweet, as the Extra Dry on the label tells us. It possesses just the right amount of acidity to balance off the slight sweetness to deliver a very refreshing glass of wine. It has wonderful floral and citrus notes on the nose (perhaps a bit of orange blossom and lemon grass?). It starts off a bit round and creamy, but has a long clean finish punctuated with lingering crisp citrus.

This is currently one of my favorite wines, one I buy by-the-case. If you are looking for something a bit different, and have not enjoyed prosecco in the past, give this one a try. I think you will enjoy it, and it may become one of you favorite wines as well.

Posted in Wine | Leave a comment

How to validate a URL with a Scheme and Hostname in Zend Framework

I recently ran across a situation where URLs where being stored in the database with the scheme and the hostname (e.g., http://www.rondobley.com/2011). The validator that was being used was allowing URLs like http://rondobley to pass validation. The validation code was:

if (!Zend_Uri::check($value)) {
    $this->_error(self::INVALID_URL);
    return false;
}

Zend_Uri::check() will parse the URI and return a scheme handler class based on the scheme and then validate the URI. Currently, the only schemes supported are http(s), however, in the future mailto will be supported as well. So, we end up with an instance of Zend_Uri_Http which then calls the valid() method. This is where we run into our problem. Zend_Uri_Http->valid() validates all parts of the URI, however, when it validates the hostname, it does so with:

// Check the host against the allowed values; delegated to Zend_Filter.
$validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);

Notice here it overrides the Zend_Validate_Hostname default option to Zend_Validate_Hostname::ALLOW_ALL which allows localhost names to validate.

In order to solve this problem and validate the URLs as we stored them I broke the process down into two steps. First, I create a new Zend_Uri_Http object using the fromString() method. This will ensure that we have a scheme of http(s). If not, we can invalidate the URL now.

//get a Zend_Uri_Http object for our URL, this will only accept http(s) schemes
try {
    $uriHttp = Zend_Uri_Http::fromString($value);
} catch (Zend_Uri_Exception $e) {
    $this->_error(self::INVALID_URL);
    return false;
}

If we are valid at this point, we can move on to checking for a valid TLD hostname. First, we get an instance of Zend_Validate_Hostname and pass in the option Zend_Validate_Hostname::ALLOW_DNS. This really is not necessary, as that is the default option, but I just want to make it explicit that we do not want localhost names to validate. Next, we call the isValid() method passing in our hostname that we can conveniently access via our Zend_Uri_Http object.

//if we have a valid URI then we check the hostname for valid TLDs, and not local urls
$hostnameValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS); //do not allow local hostnames, this is the default

if (!$hostnameValidator->isValid($uriHttp->getHost())) {
    $this->_error(self::INVALID_URL);
    return false;
}

return true;

So now we have a validator that will validate the schemes http(s) and TLD hostname. Here the complete validator:

/**
 *
 * @author Ron Dobley
 */
<?php class Rwd_Validate_IsUrl extends Zend_Validate_Abstract {
     /**
      * Error codes
      * @const string
      */
     const INVALID_URL = 'invalidUrl';
     /**
      * Error messages
      * @var array
      */
     protected $_messageTemplates = array(self::INVALID_URL = "'%value%' is not a valid URL. It must start with http(s):// and be valid.");

    /**
     * Defined by Zend_Validate_Interface
     *
     * Returns true if and only if the $value is a valid url that starts with http(s)://
     * and the hostname is a valid TLD
     *
     * @param  string $value
     * @throws Zend_Validate_Exception if a fatal error occurs for validation process
     * @return boolean
     */
    public function isValid($value)
    {
        if (!is_string($value)) {
		    $this->_error(self::INVALID_URL);
		    return false;
		}

        $this->_setValue($value);
        //get a Zend_Uri_Http object for our URL, this will only accept http(s) schemes
        try {
            $uriHttp = Zend_Uri_Http::fromString($value);
        } catch (Zend_Uri_Exception $e) {
            $this->_error(self::INVALID_URL);
            return false;
        }

        //if we have a valid URI then we check the hostname for valid TLDs, and not local urls
        $hostnameValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS); //do not allow local hostnames, this is the default

        if (!$hostnameValidator->isValid($uriHttp->getHost())) {
            $this->_error(self::INVALID_URL);
            return false;
        }
        return true;
    }
}

Feel free to use this in your own projects, as well as leave comments for improvements.

You can find the complete class at https://github.com/rondobley/Zend-Framework-Validate-URL

Posted in Coding, Programming and Development | Leave a comment

Hello world!

Welcome to my new blog. I kept the default title for this first post because “Hello, World!” is ubiquitous in programming. I will primarily post things here that relate to coding and PHP development as well as occasional posts about my other two passions cycling and wine. My primary goal is to post solutions to the everyday problems I face as a programmer. If I run into a good wine I may post about that as well. Since I love to cycle and follow professional cycling I may post a rant or two from time to time. Anyway, this is my little spot on the web . . . thanks for stopping by.

Posted in Uncategorized | 1 Comment