Currently I'm trying to figure out how to handle the form field validation of a TextType field in Symfony2's form builder context.
There is a field that should explicitly be filled manually with one of two possible values ([email=all], [email=test]). It's intended to be some security feature to assure that the user is definitely aware of what he's doing next.
I'm wondering if there is a validation constraint that can be used to validate the field's input value to fit one of the two known options. Either [email=all] or [email=test]. In plain PHP i would do like so
function isValid($value){
$options = array("[email=all]","[email=test]");
return (in_array($value, $options)) ? true : false;
}
I'm aware that I'd build a custom validation constraint but maybe this could even be solved with Symfony standard constraints?
Thanks in advance!