Rock.Data.RouteAttribute.IsValid C# (CSharp) Method

IsValid() public method

Determines whether the specified value of the object is valid.
public IsValid ( object value ) : bool
value object The value of the object to validate.
return bool
        public override bool IsValid( object value )
        {
            try
            {
                string routeText = ( value as string );
                Route testRoute = new Route( routeText, null );
                return true;
            }
            catch ( Exception ex )
            {
                string[] exceptionLines = ex.Message.Split( new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries );

                // just get first line of message, and escape any braces that might be in it
                ErrorMessage = exceptionLines[0].Replace( "{", "{" ).Replace( "}", "}" );
                return false;
            }
        }
RouteAttribute