@ -110,21 +110,17 @@ module.exports = function generateValidator(rule, name = "<unknown>", registry)
}
};
}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){
/* 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. */
letactualRule=registry._traits.get(rule._name);
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. */
returnnewerrors.ValidationError(`Expected object of a type with the ${rule._name} trait, got ${getValueType(value)} instead`);
}
};
}elseif(rule._isSelfRule===true){
baseRule=function(value){
if(valueinstanceofthis._type){
@ -195,7 +191,7 @@ module.exports = function generateValidator(rule, name = "<unknown>", registry)
});
}
}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. */