# enaml.validator

Classes

`FloatValidator` | A concrete Validator which handles floating point input.
`IntValidator` | A concrete Validator which handles integer input.
`RegexValidator` | A concrete Validator which handles text input.
`Validator` | The base class for creating widget text validators.

class enaml.validator.FloatValidator

  Bases: `Validator`

  A concrete Validator which handles floating point input.

  This validator ensures that the text represents a floating point number within a specified range.

  minimum

    The minimum value allowed for the float, inclusive, or None if there is no lower bound.

  maximum

    The maximum value allowed for the float, inclusive, or None if there is no upper bound.

  allow_exponent

    Whether or not to allow exponents like ‘1e6’ in the input.

  validate(text)

    Validates the given text matches the float range.

    Parameters:

      text (unicode) – The unicode text edited by the client widget.

    Returns:

      result – True if the text is valid, False otherwise.

    Return type:

      bool

class enaml.validator.IntValidator

  Bases: `Validator`

  A concrete Validator which handles integer input.

  This validator ensures that the text represents an integer within a specified range in a specified base.

  minimum

    The minimum value allowed for the int, inclusive, or None if there is no lower bound.

  maximum

    The maximum value allowed for the int, inclusive, or None if there is no upper bound.

  base

    The base in which the int is represented.

  validate(text)

    Validates the given text matches the integer range.

    Parameters:

      text (unicode) – The unicode text edited by the client widget.

    Returns:

      result – True if the text is valid, False otherwise.

    Return type:

      bool

class enaml.validator.RegexValidator

  Bases: `Validator`

  A concrete Validator which handles text input.

  This validator ensures that the text matches a provided regular expression string.

  regex

    The regular expression string to use for validation. The default regex matches everything.

  validate(text)

    Validates the given text matches the regular expression.

    Parameters:

      text (unicode) – The unicode text edited by the client widget.

    Returns:

      result – True if the text is valid, False otherwise.

    Return type:

      bool

class enaml.validator.Validator

  Bases: `Atom`

  The base class for creating widget text validators.

  This class is abstract. It’s abstract api must be implemented by a subclass in order to be usable.

  message

    An optional message to associate with the validator. This message may be used by the toolkit to display information to the user about what went wrong.

  validate(text)

    Validate the text as the user types.

    This method is called on every keystroke to validate the text as the user inputs characters. It should be efficient. This is an abstract method which must be implemented by subclasses.

    Parameters:

      text (unicode) – The unicode text entered by the user.

    Returns:

      result – True if the text is valid, False otherwise.

    Return type:

      bool

  fixup(text)

    An optional method to fix invalid user input.

    This method will be called if user attempts to apply text which is not valid. This method may convert the text to a valid form. The returned text will be retested for validity. The default implementation of this method is a no-op.

    Returns:

      result – The optionally modified input text.

    Return type:

      unicode