[open-ils-commits] r16629 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jun 9 00:57:14 EDT 2010
Author: scottmk
Date: 2010-06-09 00:57:10 -0400 (Wed, 09 Jun 2010)
New Revision: 16629
Modified:
trunk/Open-ILS/src/c-apps/idlval.c
Log:
Recognize new "required" and "validate" attributes for <field> element.
M Open-ILS/src/c-apps/idlval.c
Modified: trunk/Open-ILS/src/c-apps/idlval.c
===================================================================
--- trunk/Open-ILS/src/c-apps/idlval.c 2010-06-08 21:01:27 UTC (rev 16628)
+++ trunk/Open-ILS/src/c-apps/idlval.c 2010-06-09 04:57:10 UTC (rev 16629)
@@ -770,7 +770,7 @@
rc = 1;
} else if( DT_ID == field->datatype && ! sequence && ! class->is_virtual ) {
printf(
- "Line %ld: Primary key is an id; class \"%s\" should have a sequence attribute\n",
+ "Line %ld: Primary key is an id; class \"%s\" may need a sequence attribute\n",
xmlGetLineNo( fields ), id );
rc = 1;
} else if( DT_ID != field->datatype
@@ -1117,6 +1117,29 @@
rc = 1;
}
xmlFree( primitive );
+ } else if( !strcmp( attr_name, "validate" )) {
+ xmlChar* validate = xmlGetProp( field, (xmlChar*) "validate" );
+ if( !*validate ) {
+ // Value should be a regular expression to define a validation rule
+ printf( "Line %ld: Empty value for \"validate\" attribute "
+ "for field \"%s\" in class \"%s\"\n",
+ xmlGetLineNo( field ), (char*) field_name ? : "", id );
+ rc = 1;
+ }
+ xmlFree( validate );
+ // To do: verify that the namespace is oils_obj
+ } else if( !strcmp( attr_name, "required" )) {
+ xmlChar* required = xmlGetProp( field, (xmlChar*) "required" );
+ if( strcmp( (char*) required, "true" ) && strcmp( (char*) required, "false" )) {
+ printf(
+ "Line %ld: Invalid value \"%s\" for \"required\" attribute "
+ "for field \"%s\" in class \"%s\"\n",
+ xmlGetLineNo( field ), (char*) required,
+ (char*) field_name ? : "", id );
+ rc = 1;
+ }
+ xmlFree( required );
+ // To do: verify that the namespace is oils_obj
} else {
printf( "Line %ld: Unexpected field attribute \"%s\" in class \"%s\"\n",
xmlGetLineNo( field ), attr_name, id );
More information about the open-ils-commits
mailing list