@@ -291,20 +291,18 @@ class Validator {
291291 // Message needs
292292 for ( const value of splitValues ) {
293293 let parse_error = false ;
294+ let parsed_ok = false ;
294295 if ( slotType ) {
295296 // Doesn't pertain to slots which are ONLY enumerations.
296297 const parsed = this . #parser. parse ( value , slotType . uri ) ;
297298
298- // Issue: parse can fail on decimal but menu has "Missing"
299299 if ( parsed === undefined ) {
300- parse_error = `Value does not match format for ${ slotType . uri } ` ;
301-
302- //if (!(anyOfValidators.length || allOfValidators.length || exactlyOneOfValidators.length || noneOfValidators.length)) {
303- // return parse_error;
304- //}
300+ // Basic type check failed - return immediately with a clear type error.
301+ // any_of/all_of/etc sub-validators can't meaningfully evaluate a
302+ // value that already fails the declared top-level range type.
303+ return `Value does not match format for ${ slotType . uri } ` ;
305304 }
306- // All these cases have encountered an item which matches basic data
307- // datatype and so sudden death is ok.
305+ // Value parsed successfully as the declared type.
308306 else {
309307 if ( slotMinimumValue !== undefined && parsed < slotMinimumValue ) {
310308 return 'Value is less than minimum value' ;
@@ -330,17 +328,19 @@ class Validator {
330328 return 'Value does not match pattern' ;
331329 }
332330
333- // Here slotType value tested and is ok!
334- continue ;
331+ // Basic type constraints passed. Fall through to any_of/all_of/etc
332+ // checks below, which may impose additional structural constraints.
333+ parsed_ok = true ;
335334 }
336335
337- // Here value didn't parse to slotType
336+ // Here value didn't parse to slotType (already returned above).
338337 } else {
339338 // No basic slot type here so only enumeration handling.
340339 }
341340
342- // Single range for slot given so no need to evaluate all_of, any_of etc.
343- if ( slotEnum && ! slotPermissibleValues . includes ( value ) ) {
341+ // Enum check only for values that did not pass a basic type check.
342+ // (A typed value that passes its type check is not subject to enum restriction.)
343+ if ( ! parsed_ok && slotEnum && ! slotPermissibleValues . includes ( value ) ) {
344344 return 'Value is not allowed' ;
345345 }
346346
@@ -384,15 +384,20 @@ class Validator {
384384 }
385385 }
386386
387+ // Typed value passed all basic and structural constraint checks.
388+ if ( parsed_ok ) {
389+ continue ;
390+ }
391+
387392 if (
388393 anyOfValidators . length ||
389394 allOfValidators . length ||
390395 exactlyOneOfValidators . length ||
391396 noneOfValidators . length
392397 ) {
393- // We passed validation here which means a parse error can be overriden
398+ // Passed validation via constraint validators; any parse error overridden.
394399 } else if ( parse_error . length ) {
395- //There were no other ranges besides basic slotType so
400+ // No constraint validators present and basic type check failed.
396401 return parse_error ;
397402 }
398403 }
0 commit comments