From e8c32ab5843c9ab486233be5f293857047dd8fb3 Mon Sep 17 00:00:00 2001 From: scottmk Date: Wed, 9 Jun 2010 04:57:10 +0000 Subject: [PATCH] Recognize new "required" and "validate" attributes for element. M Open-ILS/src/c-apps/idlval.c git-svn-id: svn://svn.open-ils.org/ILS/trunk@16629 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/c-apps/idlval.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/c-apps/idlval.c b/Open-ILS/src/c-apps/idlval.c index 1e25334e01..d786484531 100644 --- a/Open-ILS/src/c-apps/idlval.c +++ b/Open-ILS/src/c-apps/idlval.c @@ -770,7 +770,7 @@ static int val_fields_attributes( Class* class, const char* id, xmlNodePtr field 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 @@ static int val_one_field( Class* class, const char* id, xmlNodePtr field ) { 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 ); -- 2.43.2