Hi,
You can add the data validation to a field using the below code.
this.Errors.Add(<node of the field to which you want to add validation>, "<name of the validation>", "<message>");
You need to add this code by checking whether the pattern is correct or not using if condition.