I can haz help text? ;)
| Project: | Validation API |
| Version: | 6.x-1.0-alpha1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
I found myself completely lost when I arrived at admin/build/validation_api/validators/add, and actually had to import the length validator and edit it in order to get some clue of what to do here.
Type: What is a "type" of validator? Is this a 'free-form' method of 'tagging' validators so they appear together? Are there only specific types I can choose from? Is this the type of /validator/ or the type of fields to which it can be attached?
Rule: Please can we put a couple examples here? I understand how to write regular expressions, but don't know what this form field is looking for.
Arguments: I noticed the form doesn't allow the ability to add arguments, but the length validator had one when I imported it. How do I add arguments to my validator, and how do I use them in my regex?
Message: Mention that there are placeholders for things like the field name, the value, etc.

#1
Bumping this to critical, since it's going to block people from testing.
#2
Type is being changed to a select box, since you either enter php or regex in this field.
Rule will be filled with a better description, that will explain what to do if you select php or regex with quick examples.
Arguments will be a part of the description for the rule and message explaining the placeholders and their capabilities.
I will be working on this in the next few days, and post the changes.
#3
I think using validation_api_help() here to provide some easily readable examples would be appropriate here instead of cramming things into #description on each field.
http://drupal.org/node/283958 marked duplicate of this issue.
#4
hook_help is great for a longer example, and/or to explain regular expressions, for sure. But I already know regular expressions and have an idea of what I want to type in there, but I have no idea the format that the text field is looking for. Is it /[0-9]+/, is it [0-9]+, is it [0-9], is it [numeric] ...?
A simple "For example,
simple regex here. For more detailed help, please read up on regular expressions at PHP.net[link]" would suffice. But something needs to go there to tell me what input format it's expecting.#5
<?php/**
* Implementation of hook_help().
*/
function validation_api_help($path, $arg) {
switch ($path) {
case 'admin/help#validation_api':
$output = '<p>'. t('Validation API offers the ability to create a validation PHP script or Regular-Expression script to validate any field on the site.') .'</p>';
$output .= '<p>'. t('Validators are the scripts that are run to test if the field is valid. Fields are representatives of any form field on the site that you want to assign a validator to test.') .'</p>';
return $output;
case 'admin/build/validation_api':
$output = '<p>'. t('Validators are the scripts that are run to test if the field is valid. Fields are representatives of any form field on the site that you want to assign a validator to test.') .'</p>';
return $output;
case 'admin/build/validation_api/validators':
$output = '<p>'. t('This page contains all of the validators in the database. You can add/edit your own validators, import validators from other modules, import validators with code, export code for a validator, and clone validators. The update link under Ops (You may or may not see this link) is for imported validators from other modules that are now different from the one in the database.');
return $output;
case 'admin/build/validation_api/validators/add':
$output = '<p>'. t('The rule is the script that is run to validate the value passed to this validator. The code is ran in either PHP or RegEx (depending on the language type you select).') .'</p>';
$output .= '<p>'. t('If you choose PHP, you need to use $value as the value and (if applicable) use $arg as the argument in the rule. If you choose RegEx, the value will automatically be used and (if applicable) just use %arg as the argument in the rule (e.g. "/^((.)|(\s)){%arg,}$/").') .'</p>';
$output .= '<p>'. t('Messages may use placeholders to further describe the error. You need to use %field as the placeholder for the name of the field and use %arg as the placeholder for the argument.') .'</p>';
return $output;
case 'admin/build/validation_api/validators/edit/%':
$output = '<p>'. t('The rule is the script that is run to validate the value passed to this validator. The code is ran in either PHP or RegEx (depending on the language type you select).') .'</p>';
$output .= '<p>'. t('If you choose PHP, you need to use $value as the value and (if applicable) use $arg as the argument in the rule. If you choose RegEx, the value will automatically be used and (if applicable) just use %arg as the argument in the rule (e.g. "/^((.)|(\s)){%arg,}$/").') .'</p>';
$output .= '<p>'. t('Messages may use placeholders to further describe the error. You need to use %field as the placeholder for the name of the field and use %arg as the placeholder for the argument.') .'</p>';
return $output;
case 'admin/build/validation_api/validators/import':
$output = '<p>'. t('You can check any validator(s) you want imported from modules, and/or you can put code from an export into the text-area.') .'</p>';
return $output;
case 'admin/build/validation_api/validators/export':
$output = '<p>'. t('Check which validators you would like to export. After exporting, copy the code in the text-area and paste into the import text-area to import these validators on other systems.') .'</p>';
return $output;
case 'admin/build/validation_api/validators/clone':
$output = '<p>'. t('Check which validators you would like to clone. This will create a copy of that validator to the database with a number added to the end of the name.') .'</p>';
return $output;
case 'admin/build/validation_api/fields':
$output = '<p>'. t('This page contains all of the fields in the database that have been associated with a validator. You can add/edit your own fields, or you can go to the field you want to add a validator to, and click the link below to add a validator.');
return $output;
case 'admin/build/validation_api/fields/add':
$output = '<p>'. t('The Form ID is the ID of the form the field is located in. The Field Name is the name of the field you want to validate. You can get both of the fields by going to the field and using the link directly below the field.') .'</p>';
$output .= '<p>'. t('Field Name\'s can have several actual fields grouped together. You can validate all fields by just using the field name. However, if you want to validate each field below it separately, you can use indexes (e.g. field_name[0]).') .'</p>';
$output .= '<p>'. t('The Argument is an option available if you want to have one validator serve a general purpose, and each field will send an argument for the validation. For example, if you make a validator that tests the minimum-length of the field, you can use the argument to tell the validator the minimum-length of this particular field. Make sure you set-up the validator to accept these arguments, or they will not be applied properly. If you are not using an argument, you can just leave the field blank.') .'</p>';
return $output;
case 'admin/build/validation_api/fields/edit/%':
$output = '<p>'. t('The Form ID is the ID of the form the field is located in. The Field Name is the name of the field you want to validate. You can get both of the fields by going to the field and using the link directly below the field.') .'</p>';
$output .= '<p>'. t('Field Name\'s can have several actual fields grouped together. You can validate all fields by just using the field name. However, if you want to validate each field below it separately, you can use indexes (e.g. field_name[0]).') .'</p>';
$output .= '<p>'. t('The Argument is an option available if you want to have one validator serve a general purpose, and each field will send an argument for the validation. For example, if you make a validator that tests the minimum-length of the field, you can use the argument to tell the validator the minimum-length of this particular field. Make sure you set-up the validator to accept these arguments, or they will not be applied properly. If you are not using an argument, you can just leave the field blank.') .'</p>';
return $output;
}
}
?>
#6
Automatically closed -- issue fixed for two weeks with no activity.
#7
The help still doesn't seem to have one single simple example validator string in PHP or Regular Expression. I am a bit confounded by all the obvious excellent work and time that has been put into this but why this one very obvious issue has been left unaddressed even after it has obviously been brought up repeatedly.
It feels like I am given a Mercedes but the ignition is hidden away needlessly. Could someone please put up a one line simple validator string of each type so that it is clear what the module expects to be returned when the condition is not met? I would be seriously grateful.
Best regards,
KT