private List<ValidationEvent> validateTrait(
            Model model,
            NodeValidationVisitor validator,
            Shape targetShape,
            Trait trait,
            boolean validatePrelude
    ) {
        ShapeId shape = trait.toShapeId();

        if (!model.getShape(shape).isPresent()) {
            // Punt; invalid ID targets are validated in TraitDefinitionShapeValidator.
            return ListUtils.of();
        }

        if (!validatePrelude && Prelude.isPreludeShape(targetShape)) {
            // The prelude is validated through tests in smithy-model and does not
            // need to be validated here since traits can't be applied to shapes in
            // the prelude outside of the prelude.
            return ListUtils.of();
        }

        validator.setValue(trait.toNode());
        validator.setEventShapeId(targetShape.getId());
        validator.setStartingContext("Error validating trait `" + Trait.getIdiomaticTraitName(trait) + "`");
        return model.getShape(shape).get().accept(validator);
    }
Validates that trait values are valid for their trait definitions.
smithy-model/src/main/java/software/amazon/smithy/model/validation/validators/TraitValueValidator.java