Is it OK?
Yes.
In the sense that it is "correct". It matches your stated specification, as amended to include both single- and double-digit months and days.
Is it maintainable?
No, in a setting where multiple engineers who come and go
will work on the code, it is less maintainable than this regex:
^\d{4}(-\d{1,2}){0,2}$
which in turn is less maintainable than this one:
^\d{4}(-\d{1,2})?(-\d{1,2})?$
Programs must be written for people to read, and only incidentally for machines to execute.
-- Abelson & Sussman, SICP
The last regex immediately conveys the notion of y-m-d
to a newly hired engineer at a glance,
in a way that the other formulations do not.