A Candidate Instance is annotated against an Atomic Type as follows:
If it is valid against the Type (which implies that it is an atomic value), it is cast to the Atomic Type.
Otherwise, it is replaced with an object with the fields $invalid (true), $expected (Atomic Type name), $value (the Candidate Instance)
A Candidate Instance is annotated against an Object Type $t as follows:
If it is valid against the Type (which implies that it is an object), it is annotated with the Object Type's Qualified Name (if it has any).
If it is valid against the Type, each pair value associated with a key $key is annotated recursively against the Types described with $t."$content".$key."$type". For missing pairs for which a $t."$content".$key."$default" value is provided, a new pair with the (possibly computed) $default value is added.
Otherwise, it is replaced with an object with the fields $invalid (true), $expected (Object Type name), $value (the Candidate Instance)
A Candidate Instance is annotated against an Array Type $t as follows:
If it is valid against the Type (which implies that it is an array), it is annotated with the Array Type's Qualified Name (if it has any).
If it is valid against the Type, each member is annotated recursively against the Type described with $t."$content"(1).
Otherwise, it is replaced with an object with the fields $invalid (true), $expected (Array Type name), $value (the Candidate Instance)
A Candidate Instance is annotated against a Union Type $t as follows:
If it is valid against the Type, then it is annotated against the first Type of $t."$content"() against which the Candidate Instance is valid.
Otherwise, it is replaced with an object with the fields $invalid (true), $expected (Union Type name), $value (the Candidate Instance)