// $Revision: 7$
// $Date: 2007-08-17 3:06:43 PM$
// $NoKeywords$

/******************************************************************************
  Classes defined in this file:

    USER_SubscriberName 

******************************************************************************/

/******************************************************************************
  USER_SubscriberName C'tor

    Parameters:
        [in] name
******************************************************************************/
function USER_SubscriberName( name )
{
    if ( name === null || name === undefined )
    {
        throw new USER_EX_FailedNameValidation( name );
    }

    this.name = UTILS.trimLeadingAndTrailingWhiteSpace( name ); 

    this.Validate( );
}

USER_SubscriberName.prototype = 
{   
    MINIMUM_LENGTH : 2,
    MAXIMUM_LENGTH : 64, 

    /******************************************************************************
    PRIVATE METHODS
    ******************************************************************************/

    /******************************************************************************
      Validate

        Throws an exception if the subscriber name does not meet the length 
        requirements or has invalid characters.  
    ******************************************************************************/
    Validate : function()
    {
        // Only allow a-z, 0-9, .[dot] -[dash] '[apostrophe] _[underscore] in the name field
        var regex = /^[a-zA-Z0-9 \.\-'_]+$/;

        if ( ( this.name.length < this.MINIMUM_LENGTH ) || 
             ( this.name.length > this.MAXIMUM_LENGTH ) ||
             ( !regex.test( this.name ) ) ) 
        {
            throw new USER_EX_FailedNameValidation( this.name );
        }
    }
};


