Create a function in Python to validate the syntax of the given code.
code:
def myFunc(param1, param2):
    statement1
    statement2
def validate_syntax(code):
    try: 
        compile(code, '<string>', 'exec')
        return True
    except SyntaxError: 
        return False