gws.plugin.model_validator.format

Validator for correctly parsed values.

When a value from the client (e.g. an integer) cannot be parsed by the field, the field stores gws.ErrorValue instead. This validator fails for such values, so that they are reported before the feature is written.

Every field runs a default instance of this validator. A configured format validator replaces the default one, e.g. to set a custom message.

Example:

fields+ {
    name "count"
    type "integer"
    validators+ { type "format" message "Please enter a whole number" }
}

Source code: gws.plugin.model_validator.format

Package Contents

class gws.plugin.model_validator.format.Config

Bases: gws.base.model.validator.Config

Checks that a value could be parsed for the field type.

class gws.plugin.model_validator.format.Object

Bases: gws.base.model.validator.Object

Format validator object.

validate(field, feature, mc)