[api] get rid of code duplication

There is no point in having 2 places to valid package and project names
(that even work differently) - leave alone the fact that the backend and
the webui have similiar code ;(