You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
588 B
JavaScript

"use strict";
module.exports = function tagAsType(type) {
// In operation methods that can be used in multiple places with different semantic meanings (eg. `not`, `anyOf`) and where a different object type needs to be returned based on the observed input type, we use this method to 'annotate' the input based on what type it was determined to be during validation. That way, we don't need to duplicate the type-checking logic in the implementation code, which reduces the chance of bugs due to out-of-sync code.
return function (value) {
return { type: type, value: value };
};
};