Input Validation and restriction

how to make the editor only accept numbers and logical and mathematical operators ?

A plugin with a filterTransaction hook could be used to do that.

could you leave a simple example to get things clear or any link to a similar situation ?