See this existing question for validating color.
For the shapes, you could use the un-exported ggplot
function that validates the shape names
ggplot2:::translate_shape_string(4) # ok
ggplot2:::translate_shape_string("cross") # ok
ggplot2:::translate_shape_string("oops") # bad
ggplot2:::translate_shape_string(30) # bad
You can see if it throws an error or not. But because this is an unexported function, it is not guaranteed to work or be maintained in future versions of ggplot2 so use at your own risk.
Or there is code in the ggplot specs vignette vignette("ggplot2-specs", package="ggplot2")
that seems to give a list of all the possible values. you could check potential string values against that list.
shape_names <- c(
"circle", paste("circle", c("open", "filled", "cross", "plus", "small")), "bullet",
"square", paste("square", c("open", "filled", "cross", "plus", "triangle")),
"diamond", paste("diamond", c("open", "filled", "plus")),
"triangle", paste("triangle", c("open", "filled", "square")),
paste("triangle down", c("open", "filled")),
"plus", "cross", "asterisk"
)