TextField Validator not work

Hi,
I am using a TexField doesn’t bind any field, it a simply text input used for few calculation rules. I tried to enable validator properties, with standard DoubleValidator class like this, but seem that doesn’t work, if I type a letter and then press tab for change focus, any message validator is showed. What I wrong ?



This is how i validate if textfield is empty.

xml:

<field caption="DEPARTMENT" property="department"/>
@Named("fieldGroup2.department")
private TextField department;

department.setRequired(true);

@Override
protected void postValidate(ValidationErrors errors) {
    super.postValidate(errors);

    try {
        department.validate();
    } catch (ValidationException e) {
        errors.add(department, e.getDetailsMessage());
    }
}

Usually, if you simply want to permit only double / int values then you assign datatype:

From XML:

<textField id="doubleTextField"
           datatype="double"/>

Or programmatically:

TextField textField = componentsFactory.createComponent(TextField.class);
textField.setDatatype(Datatypes.get(Double.class));

Validators are used only for value validation, not for data parsing and formatting.