This is a text field that uses a regular expression to validate the contents. Good for something like a name that's restricted to alpha only, or an IP address, etc.

Uses either PCRE or POSIX regular expressions (selectable with radio box).

CommentFileSizeAuthor
#1 regex_0.module11.72 KBgregmac
regex.module11.8 KBgregmac

Comments

gregmac’s picture

StatusFileSize
new11.72 KB

Left some debug code in the module, removed

yched’s picture

This seems like a good idea.
It probably implies a lot of code duplication, though.
Wouldn't it be better to envision this as a patch to text.module ?
(possibly with the field setting stuff folded in a fieldset to avoid form cluttering...)

I'm aware that patches to "native CCK bundle" currently take much longer to get committed, but I think we should try to avoid field modules duplication

(this is not a proper review of your module, sorry :-) )

gregmac’s picture

This actually did start out as a patch to the text module, and I split it off into its own module for a couple reasons. The 'allowed values' field in text.module is redundant if you're using regex, so I didn't really know how to structure the interface in a way that wouldn't feel really kludgy (open to ideas though, of course). It's also something that not everyone will use (or in some cases, even want to provide available to clients/end-users).

There probably is some duplication, but this was my first module and look into drupal internals, so I'm not really sure what can be avoided (eg, if it's possible to call functions from text.module).

yched’s picture

A patch adding regex validation to text.module has just been submitted.

Maybe both efforts should be merged / coordinated ?

yched’s picture

yched’s picture

Status: Needs review » Closed (duplicate)

My view ATM is that we should privilege the approach in the issue I mentiond in #4
http://drupal.org/node/84791 (option for text.module)

So I'm marking this thread as a duplicate - we can get back to it if we eventually find a separate module more appropriate. Thanks a lot for this work, gregmac, there is probably good things to steal from it anyway.

kenorb’s picture