{
    "content": [
        {
            "type": "text",
            "text": "# Data::FormValidator (perldoc)\n\n## NAME\n\nData::FormValidator - Validates user input (usually from an HTML form) based on input profile.\n\n## SYNOPSIS\n\nuse Data::FormValidator;\nmy $results = Data::FormValidator->check(\\%inputhash, \\%dfvprofile);\nif ($results->hasinvalid or $results->hasmissing) {\n# do something with $results->invalid, $results->missing\n# or  $results->msgs\n}\nelse {\n# do something with $results->valid\n}\n\n## DESCRIPTION\n\nData::FormValidator's main aim is to make input validation expressible in a simple format.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **VALIDATING INPUT**\n- **INPUT PROFILE SPECIFICATION**\n- **VALIDATING INPUT BASED ON MULTIPLE FIELDS**\n- **MULTIPLE CONSTRAINTS**\n- **ADVANCED VALIDATION**\n- **BACKWARDS COMPATIBILITY**\n- **SEE ALSO**\n- **CREDITS**\n- **BUGS**\n- **CONTRIBUTING**\n- **AUTHOR**\n- **LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Data::FormValidator",
        "section": "",
        "mode": "perldoc",
        "summary": "Data::FormValidator - Validates user input (usually from an HTML form) based on input profile.",
        "synopsis": "use Data::FormValidator;\nmy $results = Data::FormValidator->check(\\%inputhash, \\%dfvprofile);\nif ($results->hasinvalid or $results->hasmissing) {\n# do something with $results->invalid, $results->missing\n# or  $results->msgs\n}\nelse {\n# do something with $results->valid\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "VALIDATING INPUT",
                "lines": 113,
                "subsections": []
            },
            {
                "name": "INPUT PROFILE SPECIFICATION",
                "lines": 496,
                "subsections": []
            },
            {
                "name": "VALIDATING INPUT BASED ON MULTIPLE FIELDS",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "MULTIPLE CONSTRAINTS",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "ADVANCED VALIDATION",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "BACKWARDS COMPATIBILITY",
                "lines": 108,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 44,
                "subsections": []
            },
            {
                "name": "CREDITS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "CONTRIBUTING",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Data::FormValidator - Validates user input (usually from an HTML form) based on input profile.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Data::FormValidator;\n\nmy $results = Data::FormValidator->check(\\%inputhash, \\%dfvprofile);\n\nif ($results->hasinvalid or $results->hasmissing) {\n# do something with $results->invalid, $results->missing\n# or  $results->msgs\n}\nelse {\n# do something with $results->valid\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Data::FormValidator's main aim is to make input validation expressible in a simple format.\n\nData::FormValidator lets you define profiles which declare the required and optional fields and\nany constraints they might have.\n\nThe results are provided as an object, which makes it easy to handle missing and invalid\nresults, return error messages about which constraints failed, or process the resulting valid\ndata.\n",
                "subsections": []
            },
            "VALIDATING INPUT": {
                "content": "check()\nmy $results = Data::FormValidator->check(\\%inputhash, \\%dfvprofile);\n\n\"check\" is the recommended method to use to validate forms. It returns its results as a\nData::FormValidator::Results object. A deprecated method \"validate\" described below is also\navailable, returning its results as an array.\n\nuse Data::FormValidator;\nmy $results = Data::FormValidator->check(\\%inputhash, \\%dfvprofile);\n\nHere, \"check()\" is used as a class method, and takes two required parameters.\n\nThe first a reference to the data to be be validated. This can either be a hash reference, or a\nCGI.pm-like object. In particular, the object must have a param() method that works like the one\nin CGI.pm does. CGI::Simple and Apache::Request objects are known to work in particular. Note\nthat if you use a hash reference, multiple values for a single key should be presented as an\narray reference.\n\nThe second argument is a reference to the profile you are validating.\n\nvalidate()\nmy( $valids, $missings, $invalids, $unknowns ) =\nData::FormValidator->validate( \\%inputhash, \\%dfvprofile);\n\n\"validate()\" provides a deprecated alternative to \"check()\". It has the same input syntax, but\nreturns a four element array, described as follows\n\nvalids\nThis is a hash reference to the valid fields which were submitted in the data. The data may\nhave been modified by the various filters specified.\n\nmissings\nThis is a reference to an array which contains the name of the missing fields. Those are the\nfields that the user forget to fill or filled with spaces. These fields may comes from the\n*required* list or the *dependencies* list.\n\ninvalids\nThis is a reference to an array which contains the name of the fields which failed one or\nmore of their constraint checks. If there are no invalid fields, an empty arrayref will be\nreturned.\n\nFields defined with multiple constraints will have an array ref returned in the @invalids\narray instead of a string. The first element in this array is the name of the field, and the\nremaining fields are the names of the failed constraints.\n\nunknowns\nThis is a list of fields which are unknown to the profile. Whether or not this indicates an\nerror in the user input is application dependent.\n\nnew()\nUsing \"new()\" is only needed for advanced usage, including these cases:\n\no   Loading more than one profile at a time. Then you can select the profile you want by name\nlater with \"check()\". Here's an example:\n\nmy $dfv = Data::FormValidator->new({\nprofile1 => { # usual profile definition here },\nprofile2 => { # another profile definition },\n});\n\nAs illustrated, multiple profiles are defined through a hash ref whose keys point to profile\ndefinitions.\n\nYou can also load several profiles from a file, by defining several profiles as shown above\nin an external file. Then just pass in the name of the file:\n\nmy $dfv = Data::FormValidator->new('/path/to/profiles.pl');\n\nIf the input profile is specified as a file name, the profiles will be reread each time that\nthe disk copy is modified.\n\nNow when calling \"check()\", you just need to supply the profile name:\n\nmy $results = $dfv->check(\\%inputhash,'profile1');\n\no   Applying defaults to more than one input profile. There are some parts of the validation\nprofile that you might like to re-use for many form validations.\n\nTo facilitate this, \"new()\" takes a second argument, a hash reference. Here the usual input\nprofile definitions can be made. These will act as defaults for any subsequent calls to\n\"check()\" on this object.\n\nCurrently the logic for this is very simple. Any definition of a key in your validation\nprofile will completely overwrite your default value.\n\nThis means you can't define two keys for \"constraintregexpmap\" and expect they will always\nbe there. This kind of feature may be added in the future.\n\nThe exception here is definitions for your \"msgs\" key. You will safely be able to define\nsome defaults for the top level keys within \"msgs\" and not have them clobbered just because\n\"msgs\" was defined in a validation profile.\n\nOne way to use this feature is to create your own sub-class that always provides your\ndefaults to \"new()\".\n\nAnother option is to create your own wrapper routine which provides these defaults to\n\"new()\". Here's an example of a routine you might put in a CGI::Application super-class to\nmake use of this feature:\n\n# Always use the built-in CGI object as the form data\n# and provide some defaults to new constructor\nsub checkform {\nmy $self = shift;\nmy $profile = shift\n|| die 'checkform: missing required profile';\n\nrequire Data::FormValidator;\nmy $dfv = Data::FormValidator->new({},{\n# your defaults here\n});\nreturn $dfv->check($self->query,$profile);\n}\n",
                "subsections": []
            },
            "INPUT PROFILE SPECIFICATION": {
                "content": "An input profile is a hash reference containing one or more of the following keys.\n\nHere is a very simple input profile. Examples of more advanced options are described below.\n\nuse Data::FormValidator::Constraints qw(:closures);\n\nmy $profile = {\noptional => [qw( company\nfax\ncountry )],\n\nrequired => [qw( fullname\nphone\nemail\naddress )],\n\nconstraintmethods => {\nemail => email(),\n}\n};\n\nThat defines some fields as optional, some as required, and defines that the field named 'email'\nmust pass the constraint named 'email'.\n\nHere is a complete list of the keys available in the input profile, with examples of each.\n\nrequired\nThis is an array reference which contains the name of the fields which are required. Any fields\nin this list which are not present or contain only spaces will be reported as missing.\n\nrequiredregexp\nrequiredregexp => qr/city|state|zipcode/,\n\nThis is a regular expression used to specify additional field names for which values will be\nrequired.\n\nrequiresome\nrequiresome => {\n# require any two fields from this group\ncityorstateorzipcode => [ 2, qw/city state zipcode/ ],\n}\n\nThis is a reference to a hash which defines groups of fields where 1 or more fields from the\ngroup should be required, but exactly which fields doesn't matter. The keys in the hash are the\ngroup names. These are returned as \"missing\" unless the required number of fields from the group\nhas been filled in. The values in this hash are array references. The first element in this\narray should be the number of fields in the group that is required. If the first field in the\narray is not an a digit, a default of \"1\" will be used.\n\noptional\noptional => [qw/meat coffee chocolate/],\n\nThis is an array reference which contains the name of optional fields. These are fields which\nMAY be present and if they are, they will be checked for valid input. Any fields not in optional\nor required list will be reported as unknown.\n\noptionalregexp\noptionalregexp => qr/province$/,\n\nThis is a regular expression used to specify additional fields which are optional. For example,\nif you wanted all fields names that begin with *user* to be optional, you could use the regular\nexpression, /^user/\n\ndependencies\ndependencies   => {\n\n# If ccno is entered, make cctype and ccexp required\n\"ccno\" => [ qw( cctype ccexp ) ],\n\n# if paytype eq 'check', require checkno\n\"paytype\" => {\ncheck => [ qw( checkno ) ],\n}\n\n# if cctype is VISA or MASTERCARD require CVV\n\"cctype\" => sub {\nmy $dfv  = shift;\nmy $type = shift;\n\nreturn [ 'cccvv' ] if ($type eq \"VISA\" || $type eq \"MASTERCARD\");\nreturn [ ];\n},\n},\n\nThis is for the case where an optional field has other requirements. The dependent fields can be\nspecified with an array reference.\n\nIf the dependencies are specified with a hash reference then the additional constraint is added\nthat the optional field must equal a key for the dependencies to be added.\n\nIf the dependencies are specified as a code reference then the code will be executed to\ndetermine the dependent fields. It is passed two parameters, the object and the value of the\nfield, and it should return an array reference containing the list of dependent fields.\n\nAny fields in the dependencies list that are missing when the target is present will be reported\nas missing.\n\ndependencygroups\ndependencygroups  => {\n# if either field is filled in, they all become required\npasswordgroup => [qw/password passwordconfirmation/],\n}\n\nThis is a hash reference which contains information about groups of interdependent fields. The\nkeys are arbitrary names that you create and the values are references to arrays of the field\nnames in each group.\n\ndependenciesregexp\ndependenciesregexp => {\nqr/Line\\d+\\ItemType$/ => sub {\nmy $dfv = shift;\nmy $itemtype = shift;\nmy $field = shift;\n\nif ($type eq 'NeedsBatteries') {\nmy ($prefix, $suffix) = split(/\\/, $field);\n\nreturn([$prefix . 'addbatteries]);\n} else {\nreturn([]);\n}\n},\n},\n\nThis is a regular expression used to specify additional fields which are dependent. For example,\nif you wanted to add dependencies for all fields which meet a certain criteria (such as multiple\nitems in a shopping cart) where you do not know before hand how many of such fields you may\nhave.\n\ndependentoptionals\ndependentoptionals => {\n# If deliveryaddress is specified then deliverynotes becomes optional\n\"deliveryaddress\" => [ qw( deliverynotes ) ],\n\n# if deliverytype eq 'collection', collectionnotes becomes optional\n\"deliverytype\" => {\ncollection => [ qw( collectionnotes ) ],\n}\n\n# if callbacktype is \"phone\" or \"email\" then additionalnotes becomes optional\n\"callbacktype\" => sub {\nmy $dfv = shift;\nmy $type = shift;\n\nif ($type eq 'phone' || $type eq 'email') {\nreturn(['additionalnotes']);\n} else {\nreturn([]);\n}\n},\n},\n\nThis is for the case where an optional field can trigger other optional fields. The dependent\noptional fields can be specified with an array reference.\n\nIf the dependent optional fields are specified with a hash reference, then an additional\nconstraint is added that the optional field must equal a key for the additional optional fields\nto be added.\n\nIf the dependent optional fields are specified as a code reference then the code will be\nexecuted to determine the additional optional fields. It is passed two parameters, the object\nand the value of the field, and it should return an array reference containing the list of\nadditional optional fields.\n\ndependentrequiresome\ndependentrequiresome => {\n# require any fields from this group if AddressID is \"new\"\nAddressID => sub {\nmy $dfv = shift;\nmy $value = shift;\n\nif ($value eq 'new') {\nreturn({\nhousenameornumber => [ 1, 'HouseName', 'HouseNumber' ],\n});\n} else {\nreturn;\n}\n},\n}\n\nSometimes a field will need to trigger additional dependencies but you only require some of the\nfields. You cannot set them all to be dependent as you might only have some of them, and you\ncannot set them all to be optional as you must have some of them. This method allows you to\nspecify this in a similar way to the equiresome method but dependent upon other values. In the\nexample above if the AddressID submitted is \"new\" then at least 1 of HouseName and HouseNumber\nmust also be supplied. See requiresome for the valid options for the return.\n\ndefaults\ndefaults => {\ncountry => \"USA\",\n},\n\nThis is a hash reference where keys are field names and values are defaults to use if input for\nthe field is missing.\n\nThe values can be code refs which will be used to calculate the value if needed. These code refs\nwill be passed in the DFV::Results object as the only parameter.\n\nThe defaults are set shortly before the constraints are applied, and will be returned with the\nother valid data.\n\ndefaultsregexpmap\ndefaultsregexpmap => {\nqr/^opt/ => 1,\n},\n\nThis is a hash reference that maps regular expressions to default values to use for matching\noptional or required fields.\n\nIt's useful if you have generated many checkbox fields with the similar names. Since checkbox\nfields submit nothing at all when they are not checked, it's useful to set defaults for them.\n\nNote that it doesn't make sense to use a default for a field handled by \"optionalregexp\" or\n\"requiredregexp\". When the field is not submitted, there is no way to know that it should be\noptional or required, and thus there's no way to know that a default should be set for it.\n\nfilters\n# trim leading and trailing whitespace on all fields\nfilters       => ['trim'],\n\nThis is a reference to an array of filters that will be applied to ALL optional and required\nfields, before any constraints are applied.\n\nThis can be the name of a built-in filter (trim,digit,etc) or an anonymous subroutine which\nshould take one parameter, the field value and return the (possibly) modified value.\n\nFilters modify the data returned through the results object, so use them carefully.\n\nSee Data::FormValidator::Filters for details on the built-in filters.\n\nfieldfilters\nfieldfilters => {\nccno => ['digit'],\n},\n\nA hash ref with field names as keys. Values are array references of built-in filters to apply\n(trim,digit,etc) or an anonymous subroutine which should take one parameter, the field value and\nreturn the (possibly) modified value.\n\nFilters are applied before any constraints are applied.\n\nSee Data::FormValidator::Filters for details on the built-in filters.\n\nfieldfilterregexpmap\nfieldfilterregexpmap => {\n# Upper-case the first letter of all fields that end in \"name\"\nqr/name$/    => ['ucfirst'],\n},\n\n'fieldfilterregexpmap' is used to apply filters to fields that match a regular expression.\nThis is a hash reference where the keys are the regular expressions to use and the values are\nreferences to arrays of filters which will be applied to specific input fields. Just as with\n'fieldfilters', you can you use a built-in filter or use a coderef to supply your own.\n\nconstraintmethods\nuse Data::FormValidator::Constraints qw(:closures);\n\nconstraintmethods => {\nccno      => ccnumber({fields => ['cctype']}),\ncctype    => cctype(),\nccexp     => ccexp(),\n},\n\nA hash ref which contains the constraints that will be used to check whether or not the field\ncontains valid data.\n\nNote: To use the built-in constraints, they need to first be loaded into your name space using\nthe syntax above. (Unless you are using the old \"constraints\" key, documented in \"BACKWARDS\nCOMPATIBILITY\").\n\nThe keys in this hash are field names. The values can be any of the following:\n\no   A named constraint.\n\nExample:\n\nmyzipcodefield     => zip(),\n\nSee Data::FormValidator::Constraints for the details of which built-in constraints that are\navailable.\n\no   A perl regular expression\n\nExample:\n\nmyzipcodefield   => qr/^\\d{5}$/, # match exactly 5 digits\n\nIf this field is named in \"untaintconstraintfields\" or \"untaintregexpmap\", or\n\"untaintallconstraints\" is effective, be aware of the following: If you write your own\nregular expressions and only match part of the string then you'll only get part of the\nstring in the valid hash. It is a good idea to write you own constraints like /^regex$/.\nThat way you match the whole string.\n\no   a subroutine reference, to supply custom code\n\nThis will check the input and return true or false depending on the input's validity. By\ndefault, the constraint function receives a Data::FormValidator::Results object as its first\nargument, and the value to be validated as the second. To validate a field based on more\ninputs than just the field itself, see \"VALIDATING INPUT BASED ON MULTIPLE FIELDS\".\n\nExamples:\n\n# Notice the use of 'pop'--\n# the object is the first arg passed to the method\n# while the value is the second, and last arg.\nmyzipcodefield => sub { my $val = pop;  return $val =~ '/^\\d{5}$/' },\n\n# OR you can reference a subroutine, which should work like the one above\nmyzipcodefield => \\&myvalidationroutine,\n\n# An example of setting the constraint name.\nmyzipcodefield => sub {\nmy ($dfv, $val) = @;\n$dfv->setcurrentconstraintname('myconstraintname');\nreturn $val =~ '/^\\d{5}$/'\n},\n\no   an array reference\n\nAn array reference is used to apply multiple constraints to a single field. Any of the above\noptions are valid entries the array. See \"MULTIPLE CONSTRAINTS\" below.\n\nFor more details see \"VALIDATING INPUT BASED ON MULTIPLE FIELDS\".\n\nconstraintmethodregexpmap\nuse Data::FormValidator::Constraints qw(:closures);\n\n# In your profile.\nconstraintmethodregexpmap => {\n# All fields that end in postcode have the 'postcode' constraint applied.\nqr/postcode$/    => postcode(),\n},\n\nA hash ref where the keys are the regular expressions to use and the values are the constraints\nto apply.\n\nIf one or more constraints have already been defined for a given field using\n\"constraintmethods\", \"constraintmethodregexpmap\" will add an additional constraint for that\nfield for each regular expression that matches.\n\nuntaintallconstraints\nuntaintallconstraints => 1,\n\nIf this field is set, all form data that passes a constraint will be untainted. The untainted\ndata will be returned in the valid hash. Untainting is based on the pattern match used by the\nconstraint. Note that some constraint routines may not provide untainting.\n\nSee Writing your own constraint routines for more information.\n\nThis is overridden by \"untaintconstraintfields\" and \"untaintregexpmap\".\n\nuntaintconstraintfields\nuntaintconstraintfields => [qw(zipcode state)],\n\nSpecifies that one or more fields will be untainted if they pass their constraint(s). This can\nbe set to a single field name or an array reference of field names. The untainted data will be\nreturned in the valid hash.\n\nThis overrides the untaintallconstraints flag.\n\nuntaintregexpmap\nuntaintregexpmap => [qr/somefield\\d/],\n\nSpecifies that certain fields will be untainted if they pass their constraints and match one of\nthe regular expressions supplied. This can be set to a single regex, or an array reference of\nregexes. The untainted data will be returned in the valid hash.\n\nThe above example would untaint the fields named \"somefield1\", and \"somefield2\" but not\n\"somefield\".\n\nThis overrides the untaintallconstraints flag.\n\nmissingoptionalvalid\nmissingoptionalvalid => 1\n\nThis can be set to a true value to cause optional fields with empty values to be included in the\nvalid hash. By default they are not included-- this is the historical behavior.\n\nThis is an important flag if you are using the contents of an \"update\" form to update a record\nin a database. Without using the option, fields that have been set back to \"blank\" may fail to\nget updated.\n\nvalidatorpackages\n# load all the constraints and filters from these modules\nvalidatorpackages => [qw(Data::FormValidator::Constraints::Upload)],\n\nThis key is used to define other packages which contain constraint routines or filters. Set this\nkey to a single package name, or an arrayref of several. All of its constraint and filter\nroutines beginning with 'match', 'valid' and 'filter' will be imported into\nData::FormValidator. This lets you reference them in a constraint with just their name, just\nlike built-in routines. You can even override the provided validators.\n\nSee Writing your own constraint routines documentation for more information\n\nmsgs\nThis key is used to define parameters related to formatting error messages returned to the user.\n\nBy default, invalid fields have the message \"Invalid\" associated with them while missing fields\nhave the message \"Missing\" associated with them.\n\nIn the simplest case, nothing needs to be defined here, and the default values will be used.\n\nThe default formatting applied is designed for display in an XHTML web page. That formatting is\nas followings:\n\n<span style=\"color:red;font-weight:bold\" class=\"dfverrors\">* %s</span>\n\nThe %s will be replaced with the message. The effect is that the message will appear in bold red\nwith an asterisk before it. This style can be overridden by simply defining \"dfverrors\"\nappropriately in a style sheet, or by providing a new format string.\n\nHere's a more complex example that shows how to provide your own default message strings, as\nwell as providing custom messages per field, and handling multiple constraints:\n\nmsgs => {\n\n# set a custom error prefix, defaults to none\nprefix=> 'error',\n\n# Set your own \"Missing\" message, defaults to \"Missing\"\nmissing => 'Not Here!',\n\n# Default invalid message, default's to \"Invalid\"\ninvalid => 'Problematic!',\n\n# message separator for multiple messages\n# Defaults to ' '\ninvalidseparator => ' <br /> ',\n\n# formatting string, default given above.\nformat => 'ERROR: %s',\n\n# Error messages, keyed by constraint name\n# Your constraints must be named to use this.\nconstraints => {\n'dateandtime' => 'Not a valid time format',\n# ...\n},\n\n# This token will be included in the hash if there are\n# any errors returned. This can be useful with templating\n# systems like HTML::Template\n# The 'prefix' setting does not apply here.\n# defaults to undefined\nanyerrors => 'someerrors',\n}\n\nThe hash that's prepared can be retrieved through the \"msgs\" method described in the\nData::FormValidator::Results documentation.\n\nmsgs - callback\n*This is a new feature. While it expected to be forward-compatible, it hasn't yet received the\ntesting the rest of the API has.*\n\nIf the built-in message generation doesn't suit you, it is also possible to provide your own by\nspecifying a code reference:\n\nmsgs  =>  \\&mymsgscallback\n\nThis will be called as a Data::FormValidator::Results method. It may receive as arguments an\nadditional hash reference of control parameters, corresponding to the key names usually used in\nthe \"msgs\" area of the profile. You can ignore this information if you'd like.\n\nIf you have an alternative error message handler you'd like to share, stick in the\n\"Data::FormValidator::ErrMsgs\" name space and upload it to CPAN.\n\ndebug\nThis method is used to print details about what is going on to STDERR.\n\nCurrently only level '1' is used. It provides information about which fields matched\nconstraintregexpmap.\n\nA shortcut for array refs\nA number of parts of the input profile specification include array references as their values.\nIn any of these places, you can simply use a string if you only need to specify one value. For\nexample, instead of\n\nfilters => [ 'trim' ]\n\nyou can simply say\n\nfilters => 'trim'\n\nA note on regular expression formats\nIn addition to using the preferred method of defining regular expressions using \"qr\", a\ndeprecated style of defining them as strings is also supported.\n\nPreferred:\n\nqr/this is great/\n\nDeprecated, but supported\n\n'm/this still works/'\n",
                "subsections": []
            },
            "VALIDATING INPUT BASED ON MULTIPLE FIELDS": {
                "content": "You can pass more than one value into a constraint routine. For that, the value of the\nconstraint should be a hash reference. If you are creating your own routines, be sure to read\nthe section labeled \"WRITING YOUR OWN CONSTRAINT ROUTINES\", in the\nData::FormValidator::Constraints documentation. It describes a newer and more flexible syntax.\n\nUsing the original syntax, one key should be named \"constraint\" and should have a value set to\nthe reference of the subroutine or the name of a built-in validator. Another required key is\n\"params\". The value of the \"params\" key is a reference to an array of the other elements to use\nin the validation. If the element is a scalar, it is assumed to be a field name. The field is\nknown to Data::FormValidator, the value will be filtered through any defined filters before it\nis passed in. If the value is a reference, the reference is passed directly to the routine.\nDon't forget to include the name of the field to check in that list, if you are using this\nsyntax.\n\nExample:\n\nccno  => {\nconstraint  => \"ccnumber\",\nparams         => [ qw( ccno cctype ) ],\n},\n",
                "subsections": []
            },
            "MULTIPLE CONSTRAINTS": {
                "content": "Multiple constraints can be applied to a single field by defining the value of the constraint to\nbe an array reference. Each of the values in this array can be any of the constraint types\ndefined above.\n\nWhen using multiple constraints it is important to return the name of the constraint that failed\nso you can distinguish between them. To do that, either use a named constraint, or use the hash\nref method of defining a constraint and include a \"name\" key with a value set to the name of\nyour constraint. Here's an example:\n\nmyzipcodefield => [\n'zip',\n{\nconstraintmethod =>  '/^406/',\nname              =>  'startswith406',\n}\n],\n\nYou can use an array reference with a single constraint in it if you just want to have the name\nof your failed constraint returned in the above fashion.\n\nRead about the \"validate()\" function above to see how multiple constraints are returned\ndifferently with that method.\n",
                "subsections": []
            },
            "ADVANCED VALIDATION": {
                "content": "For even more advanced validation, you will likely want to read the documentation for other\nmodules in this distribution, linked below. Also keep in mind that the Data::FormValidator\nprofile structure is just another data structure. There is no reason why it needs to be defined\nstatically. The profile could also be built on the fly with custom Perl code.\n",
                "subsections": []
            },
            "BACKWARDS COMPATIBILITY": {
                "content": "validate()\nmy( $valids, $missings, $invalids, $unknowns ) =\nData::FormValidator->validate( \\%inputhash, \\%dfvprofile);\n\n\"validate()\" provides a deprecated alternative to \"check()\". It has the same input syntax, but\nreturns a four element array, described as follows\n\nvalids\nThis is a hash reference to the valid fields which were submitted in the data. The data may\nhave been modified by the various filters specified.\n\nmissings\nThis is a reference to an array which contains the name of the missing fields. Those are the\nfields that the user forget to fill or filled with spaces. These fields may comes from the\n*required* list or the *dependencies* list.\n\ninvalids\nThis is a reference to an array which contains the name of the fields which failed one or\nmore of their constraint checks.\n\nFields defined with multiple constraints will have an array ref returned in the @invalids\narray instead of a string. The first element in this array is the name of the field, and the\nremaining fields are the names of the failed constraints.\n\nunknowns\nThis is a list of fields which are unknown to the profile. Whether or not this indicates an\nerror in the user input is application dependent.\n\nconstraints (profile key)\nThis is a supported but deprecated profile key. Using \"constraintmethods\" is recommended\ninstead, which provides a simpler, more versatile interface.\n\nconstraints => {\nccno      => {\nconstraint  => \"ccnumber\",\nparams        => [ qw( ccno cctype ) ],\n},\ncctype    => \"cctype\",\nccexp    => \"ccexp\",\n},\n\nA hash ref which contains the constraints that will be used to check whether or not the field\ncontains valid data.\n\nThe keys in this hash are field names. The values can be any of the following:\n\no   A named constraint.\n\nExample:\n\nmyzipcodefield     => 'zip',\n\nSee Data::FormValidator::Constraints for the details of which built-in constraints that are\navailable.\n\nhashref style of specifying constraints\nUsing a hash reference to specify a constraint is an older technique used to name a constraint\nor supply multiple parameters.\n\nBoth of these interface issues are now better addressed with \"constraintmethods\" and\n\"$self-\\\"namethis('foo')>.\n\n# supply multiple parameters\nccno  => {\nconstraint  => \"ccnumber\",\nparams      => [ qw( ccno cctype ) ],\n},\n\n# name a constraint, useful for returning error messages\nlastname => {\nname => \"endsinname\",\nconstraint => qr/name$/,\n},\n\nUsing a hash reference for a constraint permits the passing of multiple arguments. Required\narguments are \"constraint\" or \"constraintmethod\". Optional arguments are \"name\" and \"params\".\n\nA \"name\" on a constraints 'glues' the constraint to its error message in the validator profile\n(refer \"msgs\" section below). If no \"name\" is given then it will default to the value of\n\"constraint\" or \"constraintmethod\" IF they are NOT a CODE ref or a RegExp ref.\n\nThe \"params\" value is a reference to an array of the parameters to pass to the constraint\nmethod. If an element of the \"params\" list is a scalar, it is assumed to be naming a key of the\n%inputhash and that value is passed to the routine. If the parameter is a reference, then it is\ntreated literally and passed unchanged to the routine.\n\nIf you are using the older \"constraint\" over the new \"constraintmethod\" then don't forget to\ninclude the name of the field to check in the \"params\" list. \"constraintmethod\" provides access\nto this value via the \"getcurrent*\" methods (refer Data::FormValidator::Constraints)\n\nFor more details see \"VALIDATING INPUT BASED ON MULTIPLE FIELDS\".\n\nconstraintregexpmap (profile key)\nThis is a supported but deprecated profile key. Using \"constraintmethodsregexpmap\" is\nrecommended instead.\n\nconstraintregexpmap => {\n# All fields that end in postcode have the 'postcode' constraint applied.\nqr/postcode$/    => 'postcode',\n},\n\nA hash ref where the keys are the regular expressions to use and the values are the constraints\nto apply.\n\nIf one or more constraints have already been defined for a given field using \"constraints\",\nconstraintregexpmap will add an additional constraint for that field for each regular\nexpression that matches.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Other modules in this distribution:\n\nData::FormValidator::Constraints\n\nData::FormValidator::Constraints::Dates\n\nData::FormValidator::Constraints::Upload\n\nData::FormValidator::ConstraintsFactory\n\nData::FormValidator::Filters\n\nData::FormValidator::Results\n\nA sample application by the maintainer:\n\nValidating Web Forms with Perl, <http://mark.stosberg.com/Tech/perl/form-validation/>\n\nRelated modules:\n\nData::FormValidator::Tutorial\n\nData::FormValidator::Util::HTML\n\nCGI::Application::ValidateRM, a CGI::Application & Data::FormValidator glue module\n\nHTML::Template::Associate::FormValidator is designed to make some kinds of integration with\nHTML::Template easier.\n\nParams::Validate is useful for validating function parameters.\n\nRegexp::Common, Data::Types, Data::Verify, Email::Valid, String::Checker, CGI::ArgChecker,\nCGI::FormMagick::Validator, CGI::Validate\n\nDocument Translations:\n\nJapanese: <http://perldoc.jp/docs/modules/>\n\nDistributions which include Data::FormValidator\n\nFreeBSD includes a port named p5-Data-FormValidator\n\nDebian GNU/Linux includes a port named libdata-formvalidator-perl\n",
                "subsections": []
            },
            "CREDITS": {
                "content": "Some of these input validation functions have been taken from MiniVend by Michael J. Heins.\n\nThe credit card checksum validation was taken from contribution by Bruce Albrecht to the\nMiniVend program.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Bug reports and patches are welcome. Reports which include a failing Test::More style test are\nhelpful and will receive priority.\n\n<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-FormValidator>\n",
                "subsections": []
            },
            "CONTRIBUTING": {
                "content": "This project is maintained on Github <https://github.com/dnmfarrell/Data-FormValidator>.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Currently maintained by David Farrell <dfarrell@cpan.org>\n\nParts Copyright 2001-2006 by Mark Stosberg <mark at summersault.com>, (previous maintainer)\n\nCopyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc. All rights reserved. (Original\nAuthor)\n\nParts Copyright 1996-1999 by Michael J. Heins <mike@heins.net>\n\nParts Copyright 1996-1999 by Bruce Albrecht <bruce.albrecht@seag.fingerhut.com>\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This program is free software; you can redistribute it and/or modify it under the terms as perl\nitself.\n",
                "subsections": []
            }
        }
    }
}