Use named parameters and move validation into a separate module