User input validation in Bash
See here for the original answer.
See this thread for an example of validating user input in Bash.
Here is the code modified for your use case:
#!/usr/bin/bash
REGEX='^[YyNn]$'
CHECK="your_user_input_var"
if [[ ! $CHECK =~ $REGEX ]]
then
echo "Not ok"
else
echo "ok"
fi