How to use the @hapi/joi.date function in @hapi/joi

To help you get started, we’ve selected a few @hapi/joi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github outmoded / lout / test / routes / default.js View on Github external
{
        method: 'GET',
        path: '/withconditionalalternatives',
        options: {
            handler: () => 'ok',
            validate: {
                query: Joi.object({
                    param1: Joi.alternatives()
                        .when('b', {
                            is: 5,
                            then: Joi.string(),
                            otherwise: Joi.number().required().description('Things and stuff')
                        })
                        .when('a', {
                            is: true,
                            then: Joi.date(),
                            otherwise: Joi.any()
                        }),
                    param2: Joi.alternatives()
                        .when('b', {
                            is: 5,
                            then: Joi.string()
                        })
                        .when('a', {
                            is: true,
                            otherwise: Joi.any()
                        })
                })
            }
        }
    },
    {
github brave-intl / bat-ledger / ledger / controllers / wallet.js View on Github external
v2.getStats = {
  handler: getStats(singleDateQuery),

  auth: {
    strategy: 'simple-scoped-token',
    scope: ['global', 'stats'],
    mode: 'required'
  },

  description: 'Retrieves information about wallets',
  tags: [ 'api' ],

  validate: {
    params: Joi.object().keys({
      from: Joi.date().iso().required().description('the date to query for'),
      until: Joi.date().iso().optional().description('the non inclusive date to query until')
    }).unknown(true)
  },
  response: {
    schema: walletStatsList
  }
}

function singleDateQuery ({
  params
}) {
  const {
    from,
    until
  } = params
  const baseDate = new Date(from)
  const DAY = 1000 * 60 * 60 * 24
github devinivy / hapipal-realworld-example-app / lib / models / comment.js View on Github external
static get joiSchema() {

        return Joi.object({
            id: Joi.number().integer().greater(0),
            createdAt: Joi.date(),
            updatedAt: Joi.date(),
            authorId: Joi.number().integer().greater(0).required(),
            articleId: Joi.number().integer().greater(0).required(),
            body: Joi.string().required()
        });
    }
github entropic-dev / entropic / services / storage / models / authentication.js View on Github external
}
};

const User = require('./user');

module.exports.objects = orm(module.exports, {
  id: joi
    .number()
    .integer()
    .greater(-1)
    .required(),
  user: orm.fk(User),
  remote_identity: joi.string(),
  provider: joi.any().allow(['github']),
  access_token_enc: joi.string(),
  created: joi.date(),
  modified: joi.date(),
  active: joi.boolean().default(true)
});
github mattboutet / user-pal / lib / models / Users.js View on Github external
static get joiSchema() {

        return Joi.object({

            id: Joi.number().integer().min(1),
            email: Joi.string().email(),
            password: Joi.binary().allow(null),
            firstName: Joi.string(),
            lastName: Joi.string(),
            role: Joi.string().valid(['admin', 'user']),
            resetToken: Joi.binary().allow(null),
            createdAt: Joi.date().iso(),
            updatedAt: Joi.date().iso()
        });
    }
github minhuyen / generator-expressjs-rest / generators / app / templates / backend / src / api / auth / auth.validation.js View on Github external
.lowercase()
    .required(),
  username: Joi.string()
    .min(5)
    .required(),
  password: Joi.string()
    .min(6)
    .required()
    .strict(),
  accountType: Joi.string()
    .valid('caller', 'receive_call', 'both')
    .required(),
  gender: Joi.string()
    .valid('female', 'male', 'unknown')
    .required(),
  birthday: Joi.date()
    .greater('1-1-1900')
    .required(),
  about: Joi.string()
    .allow('')
    .optional()
});

export const loginValidationSchema = Joi.object({
  email: Joi.string()
    .email()
    .required(),
  password: Joi.string()
    .min(6)
    .max(255)
    .required()
});
github entropic-dev / entropic / services / storage / models / token.js View on Github external
this.#user = Promise.resolve(u);
    this.user_id = this.#user.id;
  }
};

module.exports.objects = orm(module.exports, {
  id: joi
    .number()
    .integer()
    .greater(-1)
    .required(),
  user: orm.fk(User),
  value_hash: joi.string(),
  description: joi.string(),
  created: joi.date(),
  modified: joi.date(),
  active: joi.boolean().default(true)
});
github entropic-dev / entropic / services / storage / models / package-version.js View on Github external
.greater(-1)
    .required(),
  version: joi.string().min(1),
  parent: orm.fk(Package),
  yanked: joi.boolean().default(false),
  files: joi.object().unknown(),
  derivedFiles: joi.object().unknown(),
  signatures: joi.array().items(joi.string()),
  dependencies: joi.object().unknown(),
  devDependencies: joi.object().unknown(),
  peerDependencies: joi.object().unknown(),
  optionalDependencies: joi.object().unknown(),
  bundledDependencies: joi.object().unknown(),
  active: joi.boolean().default(true),
  created: joi.date(),
  modified: joi.date()
});
github inaturalist / iNaturalistAPI / openapi / schema / response / project.js View on Github external
longitude: Joi.string( ),
  place_id: Joi.number( ).integer( ).valid( null ),
  project_observation_fields: Joi.array( ).items( Joi.object( ).keys( {
    id: Joi.number( ).integer( ),
    observation_field: observationField,
    position: Joi.number( ).integer( ),
    required: Joi.boolean( ).valid( null )
  } ).unknown( false ) ),
  project_observation_rules: Joi.array( ).items( Joi.object( ).keys( {
    id: Joi.number( ).integer( ),
    operand_id: Joi.number( ).integer( ).valid( null ),
    operand_type: Joi.string( ).valid( null ),
    operator: Joi.string( )
  } ).unknown( false ) ),
  project_type: Joi.string( ).valid( null ),
  rule_preferences: Joi.array( ).items( Joi.date( ) ),
  search_parameters: Joi.array( ).items( Joi.object( ).keys( {
    field: Joi.string( ),
    value: Joi.any( ).description( "TODO: values can be single values or arrays" ),
    value_bool: Joi.boolean( ),
    value_date: Joi.array( ).items( Joi.string( ) ),
    value_keyword: Joi.any( ).description( "TODO: values can be single values or arrays" ),
    value_number: Joi.array( ).items( Joi.number( ) )
  } ).unknown( false ) ),
  site_features: Joi.array( ).items( Joi.date( ) ).description( "TODO: fix this" ),
  slug: Joi.string( ),
  title: Joi.string( ),
  updated_at: Joi.string( ),
  user_id: Joi.number( ).integer( ),
  user_ids: Joi.array( ).items( Joi.number( ).integer( ) )
} ).unknown( false ).meta( { className: "Project" } )
  .valid( null );
github HelpAssistHer / help-assist-her / server / pregnancy-centers / schema / joi-schema.js View on Github external
},
	updated: {
		address: dateUserActionSchemaJoi,
		doNotList: dateUserActionSchemaJoi,
		email: dateUserActionSchemaJoi,
		hotlinePhoneNumber: dateUserActionSchemaJoi,
		hours: dateUserActionSchemaJoi,
		notes: dateUserActionSchemaJoi,
		outOfBusiness: dateUserActionSchemaJoi,
		phone: dateUserActionSchemaJoi,
		prcName: dateUserActionSchemaJoi,
		primaryContactPerson: dateUserActionSchemaJoi,
		services: dateUserActionSchemaJoi,
		website: dateUserActionSchemaJoi,
	},
	updatedAt: Joi.date().iso(),
	website: Joi.string()
		.uri()
		.allow(''),
})

module.exports = pregnancyCenterSchemaJoi