How to use the kiwi.datatypes.ValidationError function in kiwi

To help you get started, we’ve selected a few kiwi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoq / stoq / stoqlib / gui / slaves / productslave.py View on Github external
def on_minimum_quantity__validate(self, widget, value):
        if value and value < 0:
            return ValidationError(_(u'Minimum value must be a positive value.'))

        maximum = self.maximum_quantity.read()
        if maximum and value > maximum:
            return ValidationError(_(u'Minimum must be lower than the '
                                     'maximum value.'))
github stoq / stoq / stoqlib / gui / slaves / paymentslave.py View on Github external
def on_value__validate(self, widget, value):
        if value < currency(0):
            return ValidationError(_(u"The value must be "
                                     "a positive number"))
github stoq / stoq / stoqlib / gui / editors / purchaseeditor.py View on Github external
def on_quantity_returned__validate(self, widget, value):
        if value < self._original_returned_qty:
            return ValidationError(_(u'Can not decrease this quantity.'))

        max_returned = self.model.quantity_received - self.quantity_sold.read()
        if value and value > max_returned:
            return ValidationError(_(u'Invalid returned quantity'))
github stoq / stoq / stoqlib / gui / editors / paymentmethodeditor.py View on Github external
def _validate_range(self, start, end):
        if ValueUnset in [start, end]:
            return

        if start > end:
            return ValidationError(_('Installments start should be lower '
                                     'or equal installments end'))

        if not CardOperationCost.validate_installment_range(
                device=self.model.device,
                provider=self.model.provider, card_type=self.model.card_type,
                start=start, end=end, ignore=self.model.real_model.id,
                store=self.store):
            return ValidationError(_('The installments range is conflicting '
                                     'with another configuration'))
github stoq / stoq / plugins / ecf / ecfmemorydialog.py View on Github external
def on_start_reductions_number__validate(self, widget, number):
        if number <= 0:
            return ValidationError(_("This number must be positive "
                                     "and greater than 0"))
        self.end_reductions_number.set_range(number, 9999)
github stoq / stoq / plugins / ecf / paulistainvoicedialog.py View on Github external
def on_document__validate(self, widget, value):
        # this will allow the user to use an empty value to this field
        if self.document.is_empty():
            return
        if self.cpf.get_active() and not validate_cpf(value):
            return ValidationError(_(u"The CPF is not valid."))
        elif self.cnpj.get_active() and not validate_cnpj(value):
            return ValidationError(_(u"The CNPJ is not valid."))
github stoq / stoq / plugins / optical / opticalslave.py View on Github external
def _on_frame_field_validate(self, widget, value, field):
        if value == 0:
            return

        min_v, max_v, digits, step_incr, page_incr = self.frame_widgets[field]
        if not min_v <= value <= max_v:
            return ValidationError(_(u'Value is out of range'))

        if value % step_incr != 0:
            return ValidationError(_(u'Value must be multiple of %s') %
                                   step_incr)
github stoq / stoq / stoqlib / gui / slaves / userslave.py View on Github external
def on_password__validate(self, entry, password):
        if len(password) < MINIMUM_PASSWORD_CHAR_LEN:
            return ValidationError(_(u"Passwords must have at least %d characters")
                                   % MINIMUM_PASSWORD_CHAR_LEN)
        if ((self.model.confirm_password and self._confirm_password) and
                password != self.confirm_password.get_text()):
            return ValidationError(_(u"Passwords don't matches"))
github stoq / stoq / stoqlib / gui / editors / saleeditor.py View on Github external
def _validate_quantity(self, new_quantity, allow_zero=False):
        if not allow_zero and new_quantity <= 0:
            return ValidationError(_(u"The quantity should be "
                                     u"greater than zero."))
        sellable = self.model.sellable
        if not sellable.is_valid_quantity(new_quantity):
            return ValidationError(_(u"This product unit (%s) does not "
                                     u"support fractions.") %
                                   sellable.unit_description)
github stoq / stoq / stoqlib / gui / slaves / paymentslave.py View on Github external
def on_first_duedate__validate(self, widget, value):
        if sysparam.get_bool('ALLOW_OUTDATED_OPERATIONS'):
            return

        if value < datetime.date.today():
            self.payment_list.clear_payments()
            return ValidationError(_("Expected first installment date must be "
                                     "set to a future date"))