CMDBuild Forum

Validation Rule guide

After the disaster of the last CMMS we had I wanted to add some validation for some of the text fields however all I can find in the manual or elsewhere is I can use JavaScript to have validation but zero examples or anything.

Can anyone assist me with some examples for various validation rules. At the moment I am trying to do something simple like not allowing spaces in the text field but would like to expand later to phone number formatting and other stuff.

I can really use some guidance.

In OpenMaint2.0 sample DB you got someone.

For exmple:
for WorkingCalendar

isCalendarDate = (!Ext.isEmpty(api.getValue("OccurrenceType")) && api.getLookupCode("OccurrenceType") === 'CalendarDate');
isValid = api.testRegExp(/^(\d{4}|YYYY)\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/g, value);
if (isCalendarDate && !isValid) {
        return "Invalid value";
}

So in this example it gives an error popup? What if I just don’t want the save button activated?
My first foray into it will be simply not allowing spaces or most special characters in the code field. I’ll expand onto formatting later. Both cases however I’m not really concerned with error messages just not allowing the user to save.

No pop up, as long as I remember. Only jots down in logs.
If you want menssage use the “help box tip”

You cann’t save the card, the buttom is out of service and the attbritube’s box margin remains red.
Have you tested it? Found a bug? If you test it and doesn’t run, try : Validation Rule+ Mark att. as Mandatory
Anyway I remembered that mandatory is not necesary.


I only give you a complex example for “some examples for various validation rules” first question.

I did not install the demo DB but a blank one and been constructing the sections I wanted to match our structure. Unfortunately I do not have the resources to set up another server and with the amount of hell I went through to get this one up and running I would prefer not to mess with it in that way.

I was trying to piece together from your example what I wanted to do without luck. Not the best at JavaScript. As mentioned in the original post I wanted to do something simple like not allowing spaces or other special characters. I have since noticed even if a field is set as unique I will still have to ensure either the data is all entered as uppercase because it is case sensitive. AD01, Ad01, aD01 and ad01 will be considered different codes.

Hello friends,

I have a CMDBuild with a “Servers” Class. On “Code” attribute, I need to check with the user does not entered a name with specific words like a domain.

For example:
User write in Code: “abcd-domain-com” → Wrong
Correct name that is valid: “abcd” → Correct format

Please could someone give some help with this issue? What I need to do prevent this?

Thanks in advanced.
Camaratta