@@ -656,7 +656,7 @@ XDI_required_metadata(XDIFile *xdifile) {
656
656
if (ret & REQ_ELEM ) { strcat (xdifile -> error_message , "Element.symbol missing or not valid\n" ); }
657
657
if (ret & REQ_EDGE ) { strcat (xdifile -> error_message , "Element.edge missing or not valid\n" ); }
658
658
if (ret & REQ_NO_DSPACING ) { strcat (xdifile -> error_message , "Mono.d_spacing missing\n" ); }
659
- if (ret & REQ_INVALID_DSPACING ) { strcat (xdifile -> error_message , "Mono.d_spacing not valid \n" ); }
659
+ if (ret & REQ_INVALID_DSPACING ) { strcat (xdifile -> error_message , "Non-numerical value fo Mono.d_spacing\n" ); }
660
660
661
661
return ret ;
662
662
}
@@ -732,7 +732,7 @@ XDI_validate_item(XDIFile *xdifile, char *family, char *name, char *value) {
732
732
err = 0 ;
733
733
734
734
} else if (strcasecmp (family , "sample" ) == 0 ) {
735
- err = 0 ;
735
+ err = XDI_validate_sample ( xdifile , name , value ) ;
736
736
737
737
} else if (strcasecmp (family , "scan" ) == 0 ) {
738
738
err = XDI_validate_scan (xdifile , name , value );
@@ -780,6 +780,26 @@ int XDI_validate_mono(XDIFile *xdifile, char *name, char *value) {
780
780
return err ;
781
781
}
782
782
783
+ int XDI_validate_sample (XDIFile * xdifile , char * name , char * value ) {
784
+ int err ;
785
+ int regex_status ;
786
+ struct slre_cap caps [2 ];
787
+
788
+ err = 0 ;
789
+ strcpy (xdifile -> error_message , "" );
790
+
791
+ if (strcasecmp (name , "temperature" ) == 0 ) {
792
+ regex_status = slre_match ("^\\d(\\.\\d)?\\s+[CcFfKk].*$" , value , strlen (value ), caps , 2 , 0 );
793
+ if (regex_status < 0 ) {
794
+ strcpy (xdifile -> error_message , "Sample.temperature not interpretable as a temperature" );
795
+ err = WRN_BAD_SAMPLE ;
796
+ }
797
+ }
798
+
799
+ return err ;
800
+ }
801
+
802
+
783
803
int xdi_is_datestring (char * inp ) {
784
804
/* tests if input string is a valid datetime timestamp.
785
805
This uses regular expression to check format and validates
@@ -824,6 +844,7 @@ int xdi_is_datestring(char *inp) {
824
844
return 0 ;
825
845
}
826
846
847
+
827
848
int XDI_validate_scan (XDIFile * xdifile , char * name , char * value ) {
828
849
int err ;
829
850
0 commit comments