@ -110,12 +110,9 @@ module.exports = function generateValidator(rule, name = "<unknown>", registry)
}
}
};
};
}elseif(rule._isRegistryTrait===true){
}elseif(rule._isRegistryTrait===true){
if(registry==null){
thrownewError("Registry-based type rules can only be used within the context of a type registry");
}else{
baseRule=function(value){
baseRule=function(value){
/* TODO: The below approach requires that traits be defined before the types that use them, and disallows trait registry references in `.implements` calls, due to _implementedTraits always needing to contain actual trait definitions; in the future, a better approach needs to be found for this such that trait registry references can be used everywhere. */
/* TODO: The below approach requires that traits be defined before the types that use them, and disallows trait registry references in `.implements` calls, due to _implementedTraits always needing to contain actual trait definitions; in the future, a better approach needs to be found for this such that trait registry references can be used everywhere. */
@ -124,7 +121,6 @@ module.exports = function generateValidator(rule, name = "<unknown>", registry)
returnnewerrors.ValidationError(`Expected object of a type with the ${rule._name} trait, got ${getValueType(value)} instead`);
returnnewerrors.ValidationError(`Expected object of a type with the ${rule._name} trait, got ${getValueType(value)} instead`);
}
}
};
};
}
}elseif(rule._isSelfRule===true){
}elseif(rule._isSelfRule===true){
baseRule=function(value){
baseRule=function(value){
if(valueinstanceofthis._type){
if(valueinstanceofthis._type){
@ -195,7 +191,7 @@ module.exports = function generateValidator(rule, name = "<unknown>", registry)
});
});
}
}
}else{
}else{
/* FIXME: Possibly special-case (for better performance) if the only extra rule is a 'default value' rule? This would avoid a `for` loop in the case where a value is explicitly specified. */
/* TODO: Possibly special-case (for better performance) if the only extra rule is a 'default value' rule? This would avoid a `for` loop in the case where a value is explicitly specified. */