'Validate a json pointer.
We only accept a limited form of json pointers.'

def _validate_json_pointer(self, pointer):

    if (not pointer.startswith('/')):
        msg = (_('Pointer    `%s`    does    not    start    with    "/".') % pointer)
        raise webob.exc.HTTPBadRequest(explanation=msg)
    if re.search('/\\s*?/', pointer[1:]):
        msg = (_('Pointer    `%s`    contains    adjacent    "/".') % pointer)
        raise webob.exc.HTTPBadRequest(explanation=msg)
    if ((len(pointer) > 1) and pointer.endswith('/')):
        msg = (_('Pointer    `%s`    end    with    "/".') % pointer)
        raise webob.exc.HTTPBadRequest(explanation=msg)
    if (pointer[1:].strip() == '/'):
        msg = (_('Pointer    `%s`    does    not    contains    valid    token.') % pointer)
        raise webob.exc.HTTPBadRequest(explanation=msg)
    if (re.search('~[^01]', pointer) or pointer.endswith('~')):
        msg = (_('Pointer    `%s`    contains    "~"    not    part    of    a    recognized    escape    sequence.') % pointer)
        raise webob.exc.HTTPBadRequest(explanation=msg)
