[ticket/989] Move validation into it's own function