• 717 views
  • 0 comments
  • loading...

This validator matches the value against a regular expression and returns an error if it does not match.

For more information on Python regular expressions, refer to the official Python documentation.







# Here is an example of usage to validate an IPv4 address 

# (note: the IS_IPV4 validator is more appropriate for this purpose):

requires = IS_MATCH('^\d{1,3}(.\d{1,3}){3}$',
error_message='not an IP address')


Attributes / Arguments

IS_MATCH takes an optional argument strict which defaults to False. When set to True it only matches the beginning of the string

IS_MATCH('ab', strict=False)('abc')
('abc', None)

IS_MATCH('ab', strict=True)('abc')
('abc', 'Invalid expression')

IS_MATCH('...', extract=True) filters and extract only the first matching substring rather than the original value.


loading...


Comments

loading...

Powered by
Web2py

Hosted on
www.pythonanywhere.com
(affiliated link)