本文整理匯總了TypeScript中joi.date函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript date函數的具體用法?TypeScript date怎麽用?TypeScript date使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了date函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("should annotate the class property", function () {
const metadata = Reflect.getMetadata(WORKING_SCHEMA_KEY, MyClass.prototype);
const expected = {
myProperty: Joi.date(),
myOtherProperty: Joi.date(),
};
assert.deepEqual(metadata, expected);
});
示例2: saveStudent
async function saveStudent(req, res) {
try {
let data = req.body.student;
let schema = {
id: Joi.number(),
firstName: Joi.string().required(),
lastName: Joi.string().required(),
enrollmentDate: Joi.date()
};
let result = null;
let student = await helper.loadSchema(data, schema);
if (student.id) {
result = await studentRepository.updateStudent(student);
} else {
result = await studentRepository.addStudent(student);
}
return helper.sendData({data: result}, res);
} catch (err) {
helper.sendFailureMessage(err, res);
}
}
示例3: saveDepartment
async function saveDepartment(req, res) {
try {
let data = req.body.department;
let schema = {
id: Joi.number(),
name: Joi.string().required(),
budget: Joi.number().required(),
startDate: Joi.date().format(config.format.date),
instructorId: Joi.number().required()
};
let result = null;
let department = await helper.loadSchema(data, schema);
if (department.id) {
result = await departmentRepository.updateDepartment(department);
} else {
result = await departmentRepository.addDepartment(department);
}
department = await departmentRepository.getDepartmentById(result.id);
return helper.sendData({data: department}, res);
} catch (err) {
helper.sendFailureMessage(err, res);
}
}
示例4: expect
server.inject(request, (res) => {
const result = res.result as ResponsePayload.RegisterUserSuccess;
const schema = Joi.object().keys({
data: Joi.object().keys({
kind: Joi.allow("User_OwnerView"),
uuid: Joi.string().length(36),
created_at: Joi.date(),
modified_at: Joi.date(),
deleted_at: Joi.allow(null),
email: Joi.allow("a@b.c"),
is_admin: Joi.allow(false),
}),
});
let valid = Joi.validate(result, schema, {presence: "required"});
expect(res.statusCode).toEqual(200);
expect(valid.error).toEqual(null);
done();
});
示例5: saveInstructor
async function saveInstructor(req, res) {
try {
let data = req.body.instructor;
let schema = {
id: Joi.number(),
firstName: Joi.string().required(),
lastName: Joi.string().required(),
hireDate: Joi.date().format(config.format.date),
courses: Joi.array().items(
Joi.object().keys({
id: Joi.number().required()
})
),
officeAssignment: Joi.object().keys({
id: Joi.number(),
location: Joi.string().allow('')
})
};
let result = null;
let instructor = await helper.loadSchema(data, schema);
if (instructor.id) {
result = await instructorRepository.updateInstructor(instructor);
} else {
result = await instructorRepository.addInstructor(instructor);
}
await officeAssignmentRepository.saveOfficeAssignment(instructor.officeAssignment, result.id);
instructor = await instructorRepository.getInstructorById(result.id);
return helper.sendData({data: instructor}, res);
} catch (err) {
helper.sendFailureMessage(err, res);
}
}
示例6:
import * as Joi from "joi";
export const createDoorModel = Joi.object().keys({
name: Joi.string().required(),
description: Joi.string().required(),
opened: Joi.boolean().required()
});
export const updateDoorModel = Joi.object().keys({
opened: Joi.boolean().required()
});
export const doorModel = Joi.object({
_id: Joi.string().required(),
name: Joi.string().required(),
description: Joi.string().required(),
createdDate: Joi.date(),
updatedAt: Joi.date(),
opened: Joi.boolean()
}).label("Door Model").description("Json body that represents a door.");
示例7:
/**
* If specified, indicates that the task failed to accomplish its work. This is
* logged out as a warning, and the task will be reattempted after a delay.
*/
error?: object;
/**
* The state which will be passed to the next run of this task (if this is a
* recurring task). See the RunContext type definition for more details.
*/
state: object;
}
export const validateRunResult = Joi.object({
runAt: Joi.date().optional(),
error: Joi.object().optional(),
state: Joi.object().optional(),
}).optional();
export type RunFunction = () => Promise<RunResult | undefined | void>;
export type CancelFunction = () => Promise<RunResult | undefined | void>;
export interface CancellableTask {
run: RunFunction;
cancel?: CancelFunction;
}
export type TaskRunCreatorFunction = (context: RunContext) => CancellableTask;
示例8:
BlogPost
.query('werner@example.com')
.filterExpression('#title < :t')
.expressionAttributeValues({ ':t': 'Expanding' })
.expressionAttributeNames({ '#title': 'title' })
.projectionExpression('#title, tag')
.exec();
const GameScore = dynogels.define('GameScore', {
hashKey: 'userId',
rangeKey: 'gameTitle',
schema: {
userId: Joi.string(),
gameTitle: Joi.string(),
topScore: Joi.number(),
topScoreDateTime: Joi.date(),
wins: Joi.number(),
losses: Joi.number()
},
indexes: [{
hashKey: 'gameTitle', rangeKey: 'topScore', name: 'GameTitleIndex', type: 'global'
}]
});
GameScore
.query('Galaxy Invaders')
.usingIndex('GameTitleIndex')
.descending()
.exec(callback);
const GameScore1 = dynogels.define('GameScore', {
示例9:
import * as Joi from 'joi'
export const positiveInt = Joi.number().integer().min(0).optional()
const _id = Joi.number().integer().min(0).description('Unique id')
/**
* Persisted and non persisted version of types are separated in order
* to generate accurate swagger descriptions
*/
export const id: Joi.SchemaMap = { id: _id }
export const idPersisted: Joi.SchemaMap = {id: _id.required() }
export const timestamps: Joi.SchemaMap = {
created_at: Joi.date().description('Creation date'),
updated_at: Joi.date().description('Last update')
}
export const timestampsRequired: Joi.SchemaMap = {
created_at: Joi.date().required().description('Creation date'),
updated_at: Joi.date().required().description('Last update')
}
export const bool = Joi.any().valid([0, 1, true, false])
export const saneString = Joi.string().max(255).replace(/\0/gi, '')
export const saneText = Joi.string().max(1024).replace(/\0/gi, '')
示例10:
id: Joi.string()
.regex(BOTID_REGEX)
.required(),
name: Joi.string()
.max(50)
.allow('')
.optional(),
// tslint:disable-next-line:no-null-keyword
category: Joi.string().allow(null),
description: Joi.string()
.max(250)
.allow(''),
pipeline_status: {
current_stage: {
promoted_by: Joi.string(),
promoted_on: Joi.date(),
id: Joi.string()
}
},
locked: Joi.bool()
})
export const BotEditSchema = Joi.object().keys({
name: Joi.string()
.allow('')
.max(50),
// tslint:disable-next-line:no-null-keyword
category: Joi.string().allow(null),
description: Joi.string()
.max(250)
.allow(''),