The @zcloak/ctype
module defines a way to verify the credential subject(claims) data type, which is based on json-schema for validation.
yarn add @zcloak/ctype
import { validateSubject, validateSubjectPartial } from '@zcloak/ctype';
...
The Validate CType functions provide a convenient way to validate the structure of subject data based on a CType schema, allowing you to ensure that the data conforms to the expected format defined by the schema.
Key methods include:
validateSubject(params)
export function validateSubject(ctype: BaseCType, subject: any): ValidatorResult {
//......
}
Ctype
- The CType schema that defines the expected format of the subject data.Subject
- The subject data that needs to be validated.ValidatorResult
- the result from the json schema validator, indicating whether the validation was successful or not.ValidateSubjectPartial(params)
export function validateSubjectPartial(ctype: BaseCType, subject: any): ValidatorResult {
//......
}
Ctype
- The CType schema that defines the expected format of the subject data.Subject
- The partial subject data that needs to be validated.ValidatorResult
- the result from the json schema validator, indicating whether the validation was successful or not.