Extract function from register to app.js for validation

Signed-off-by: Atanas Kerezov <kerezov.atanas@gmail.com>