added validate function and invalid-action error message