• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript joi.date函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
 });
开发者ID:laurence-myers,项目名称:tsdv-joi,代码行数:8,代码来源:date.ts


示例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);
    }
}
开发者ID:yegor-sytnyk,项目名称:contoso-express,代码行数:26,代码来源:studentController.ts


示例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);
    }
}
开发者ID:Blocklevel,项目名称:contoso-express,代码行数:29,代码来源:departmentController.ts


示例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("[email protected]"),
                    is_admin: Joi.allow(false),
                }),
            });
            let valid = Joi.validate(result, schema, {presence: "required"});

            expect(res.statusCode).toEqual(200);
            expect(valid.error).toEqual(null);

            done();
        });
开发者ID:AJamesPhillips,项目名称:napthr,代码行数:21,代码来源:routes.test.ts


示例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);
    }
}
开发者ID:Blocklevel,项目名称:contoso-express,代码行数:39,代码来源:instructorController.ts


示例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.");
开发者ID:Happy-Ferret,项目名称:wachschutz,代码行数:21,代码来源:doorModel.ts


示例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;
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:29,代码来源:task.ts


示例8:

BlogPost
    .query('[email protected]')
    .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', {
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:dynogels-tests.ts


示例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, '')
开发者ID:lambrojos,项目名称:hapi-common,代码行数:26,代码来源:basic_types.ts


示例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(''),
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:31,代码来源:validation.ts



注:本文中的joi.date函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript joi.func函数代码示例发布时间:2022-05-25
下一篇:
TypeScript joi.boolean函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap