本文整理汇总了TypeScript中klay-core.IModelContext类的典型用法代码示例。如果您正苦于以下问题:TypeScript IModelContext类的具体用法?TypeScript IModelContext怎么用?TypeScript IModelContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IModelContext类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fillDefaultPasswordOptions
export function fillDefaultPasswordOptions(
context: IModelContext,
options: Partial<IPasswordOptions> = {},
): IPasswordOptions {
const model = (options.model && options.model.clone()) || context.create({type: ModelType.String})
const finalOptions: IPasswordOptions = {
secret: '',
algorithm: PasswordAlgorithm.SHA1,
saltLength: 32,
iterations: 1000,
hashedPasswordLength: 32,
...options,
model,
}
const totalLength = getTotalPasswordLength(finalOptions)
model.max(Math.min(totalLength - 1, model.spec.max || Infinity))
return finalOptions
}
示例2: fillDefaultPasswordOptions
context.password = (partialOptions: Partial<IPasswordOptions> = {}) => {
const options = fillDefaultPasswordOptions(context, partialOptions)
return context
.string()
.max(getTotalPasswordLength(options))
.password(options)
.coerce(createPasswordCoerceFn(options), ValidationPhase.ValidateChildren)
}
示例3:
context.uuidId = () =>
context
.uuid()
.constrain({type: ConstraintType.Primary})
.automanage({
property: [],
event: DatabaseEvent.Create,
phase: ValidationPhase.Parse,
supplyWith: SupplyWithPreset.UUID,
})