/** * Validate before save * * @param ValidationErrors $errors */ function validate(ValidationErrors &$errors) { parent::validate($errors); if ($this->validatePresenceOf('custom_field_1')) { if ($this->getCustomField1() < 0 || $this->getCustomField1() > 100) { $errors->addError(lang('Percent complete value must be between 0 and 100'), 'custom_field_1'); } } }