Why is it not possible to add a hyphen in the value of a custom data field? ie. I can have 'ABC_123' as a value, but I can't have 'ABC-123/100'. Attempting to enter a value like this results in "Please enter a valid value for this field. You may use a - z, A - Z, 1 - 9, spaces and underline ( _ ) characters. The length of the variable string should be less than 31 characters"
But, why is there this restriction? This is a custom data field, therefore, surely I should be able to enter any custom data I want? My client wants to have a custom data field where they can collect information from users using their own internal ID's as the values. There internal IDs have values like 'ABC-100/101' but it's not possible to enter such a value therefore my client is unable to enter the values and unable to collect the data that they need to.
My chat on IRC went a little like this:
<mrfelton> Why is it not possible to add a hyphen in the value of a custom data field? ie. I can have 'ABC_123' as a value, but I can't have 'ABC-123'
<hershel> mrfelton: Do you mean the 'value' or the 'label' of a custom field?
<mrfelton> hershel: I mean the value
hershel: "Please enter a valid value for this field. You may use a - z, A - Z, 1 - 9, spaces and underline ( _ ) characters. The length of the variable string should be less than 31 characters"
<mrfelton> what is wrong with '-' or '/' ? I can't understand the logic behinds this
These values should be escaped properly wherever they are used, so why the restriction?
<kurund> mrfelton: validation is done on purpose..
mrfelton: mostly to prevent db errors etc..
<mrfelton> kurund: I'm sure it is, but what is the purpose?
kurund: that doesn't make sense. The values should be escaped before entering in to the db at the db layer
ie, with something similar to the way db_query() works with placeholders in Drupal (I don't know much abouit the Civi db layer)
<kurund> mrfelton: i am pretty sure there was some valid reason for adding that rule. Can't remember 
So, anybody know what the reason for the restriction is? Can the CiviCRM database API not handle placeholders and escaping?