gws.plugin.model_validator.regex

Regular expression validator for strings.

Checks that the field value is a string that matches a regular expression. The match uses re.search, so the expression can match anywhere in the value; add ^ and $ anchors to match the whole value. A value that is not a string fails the check.

Example:

fields+ {
    name "zip"
    type "text"
    validators+ { type "regex" regex "^[0-9]{5}$" }
}

Source code: gws.plugin.model_validator.regex

Package Contents

class gws.plugin.model_validator.regex.Config

Bases: gws.base.model.validator.Config

Checks that a value matches a regular expression.

regex: gws.Regex

Regular expression, matched anywhere in the value unless anchored.

class gws.plugin.model_validator.regex.Object

Bases: gws.base.model.validator.Object

Regular expression validator object.

regex: str

The regular expression.

configure()
validate(field, feature, mc)