How to use the string function from joi

Find comprehensive JavaScript joi.string code examples handpicked from public code repositorys.

762
763
764
765
766
767
768
769
770
771
  auth: {
    strategy: 'sessionToken',
  },
  validate: {
    payload: isA.object({
      authPW: isA.string(),
    }),
  },
},
handler: async function (request) {
fork icon206
star icon481
watch icon43

+ 3 other calls in file

76
77
78
79
80
81
82
83
84
85
        zkPath: joi.string().required(),
        intervalS: joi.number().default(60),
    },
    site: joi.string(),
}).required(),
topic: joi.string().required(),
groupId: joi.string().required(),
queueProcessor: joi.func(),
fromOffset: joi.alternatives().try('latest', 'earliest', 'none'),
concurrency: joi.number().greater(0).default(CONCURRENCY_DEFAULT),
fork icon18
star icon51
watch icon60

+ 23 other calls in file

6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
        convert: true
    },
    failAction,

    params: Joi.object({
        app: Joi.string().max(256).required().example('AAABhaBPHscAAAAH').description('OAuth2 application ID')
    })
},

response: {
fork icon113
star icon0
watch icon16

+ 2969 other calls in file

21
22
23
24
25
26
27
28
29
30
 validate: {
  failAction,
  query: Joi.object({
   skip: Joi.number().integer().default(0),
   limit: Joi.number().integer().default(10),
   nome: Joi.string().min(3).max(100),
  }),
 },
},
handler: (request, headers) => {
fork icon0
star icon1
watch icon1

+ 62 other calls in file

608
609
610
611
612
613
614
615
616
617
router.post("/:id/email/:template", passport.authenticate(["young", "referent"], { session: false, failWithError: true }), async (req, res) => {
  try {
    const { error, value } = Joi.object({
      id: Joi.string().required(),
      template: Joi.string().required(),
      message: Joi.string().allow(null, ""),
      prevStatus: Joi.string().allow(null, ""),
      missionName: Joi.string().allow(null, ""),
      structureName: Joi.string().allow(null, ""),
      cta: Joi.string().allow(null, ""),
fork icon4
star icon8
watch icon4

+ 293 other calls in file

312
313
314
315
316
317
318
319
320
321
//Estos errores estan para que de entrada no este como error, pero que si cuando empiece a completar y deje ese
const [subjectError, setSubjectError] = useState(false);
const [bodyError, setBodyError] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const validateEmail = (email)=>{
  return joi.string().email({tlds:{allow:false}}).validate(email).error === undefined
}
const sendEmail = async()=>{
  const msg = {
    email:email,
fork icon0
star icon3
watch icon1

+ 3 other calls in file

296
297
298
299
300
301
302
303
304
305
306
307


	return res.redirect('back');
});


router.all('/no-access', validator.query(Joi.object({
	page: Joi.string()
})), (req, res, next) => {
	return res.render('no-access.hbs', {
		title: 'No Access',
		previousPage: req.query.page ?? ''
fork icon0
star icon1
watch icon1

+ 14 other calls in file

3
4
5
6
7
8
9
10
11
12
const schema = Joi.object({
  appInsights: Joi.object(),
  cache: {
    expiresIn: Joi.number().default(1000 * 3600 * 24 * 3), // 3 days
    options: {
      host: Joi.string().default('redis-hostname.default'),
      partition: Joi.string().default('ffc-techspike-authentication'),
      password: Joi.string().allow(''),
      port: Joi.number().default(6379),
      tls: Joi.object()
fork icon0
star icon1
watch icon2

+ 8 other calls in file

5
6
7
8
9
10
11
12
13
14
15
16
const S3 = new AWS.S3()
const SNS = new AWS.SNS()


const schema = Joi.object().keys({
    TodoId: Joi.string().required(),
    Task: Joi.string().required(),
    Done: Joi.string()
})


const getFileContent = async (S3, bucket, filename) => {
fork icon0
star icon1
watch icon1

+ 32 other calls in file

180
181
182
183
184
185
186
187
188
189
ppsBeneficiary: Joi.string().trim().valid("true", "false").allow("", null),
paiBeneficiary: Joi.string().trim().valid("true", "false").allow("", null),
specificAmenagment: Joi.string().trim().valid("true", "false").allow("", null),
specificAmenagmentType: Joi.string().trim().allow(""),
reducedMobilityAccess: Joi.string().trim().valid("true", "false").allow("", null),
handicapInSameDepartment: Joi.string().trim().valid("true", "false").allow("", null),
allergies: Joi.string().trim().valid("true", "false").allow("", null),

// old cohorts
imageRightFilesStatus: Joi.string().trim().valid("TO_UPLOAD", "WAITING_VERIFICATION", "WAITING_CORRECTION", "VALIDATED"),
fork icon4
star icon8
watch icon4

+ 275 other calls in file

8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
    },

    payload: Joi.object({
        action: Joi.string().valid('subscribe', 'unsubscribe').required(),
        account: Joi.string().empty('').trim().max(256).example('johnsmith').description('Account ID').required(),
        listId: Joi.string().hostname().empty('').example('test-list').label('List ID').required(),
        email: Joi.string().email().empty('').required().description('Email address').required(),
        messageId: Joi.string().empty('').max(996).example('<test123@example.com>').description('Message ID')
    })
}
fork icon113
star icon0
watch icon16

+ 461 other calls in file

324
325
326
327
328
329
330
331
332
333
        .when('accessToken', {
            is: Joi.exist().not(false, null),
            then: Joi.optional().valid(false, null),
            otherwise: Joi.required()
        }),
    accessToken: Joi.string().max(4 * 4096)
});

const { error, value } = schema.validate(authData, {
    abortEarly: false,
fork icon113
star icon0
watch icon16

+ 11 other calls in file

65
66
67
68
69
70
71
72
73
74
75


createPhase.schema = {
  phase: Joi.object()
    .keys({
      name: Joi.string().required(),
      description: Joi.string(),
      isOpen: Joi.boolean().required(),
      duration: Joi.number().positive().required(),
    })
    .required(),
fork icon44
star icon17
watch icon25

+ 55 other calls in file

1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
  memberId: Joi.string().allow(null),
}),
name: Joi.string().required(),
description: Joi.string(),
privateDescription: Joi.string(),
descriptionFormat: Joi.string(),
metadata: Joi.array()
  .items(
    Joi.object().keys({
      name: Joi.string().required(),
fork icon44
star icon17
watch icon25

+ 291 other calls in file

5064
5065
5066
5067
5068
5069
5070
5071
5072
5073

                return h.redirect('/admin').takeover();
            },

            payload: Joi.object({
                type: Joi.string().valid('totp').description('The type of the two-factor authentication method').required()
            })
        }
    }
});
fork icon113
star icon0
watch icon16

+ 643 other calls in file

78
79
80
81
82
83
84
85
86
87
validate: {
  query: Joi.alternatives().required().try(Joi.object().keys({
    easting: Joi.number().max(700000).positive().required(),
    northing: Joi.number().max(1300000).positive().required(),
    location: Joi.string().required(),
    fullName: Joi.string(),
    recipientemail: Joi.string()
  }), Joi.object().keys({
    polygon: Joi.string().required(),
    center: Joi.string().required(),
fork icon3
star icon2
watch icon11

+ 95 other calls in file

29
30
31
32
33
34
35
36
37
38
39
const Resolver = require('./resolver');
const Store = require('./store');


const schema = Joi.object({
    config: Joi.alternatives(Joi.string(), Joi.object()).required(),
    basedir: Joi.string(),
    criteria: Joi.object().default({}),
    protocols: Joi.object().default({}),
    defaults: Joi.alternatives(Joi.string(), Joi.object()).default({}),
    overrides: Joi.alternatives(Joi.string(), Joi.object()).default({})
fork icon6
star icon2
watch icon4

+ 5 other calls in file

338
339
340
341
342
343
344
345
346
347
348
349
});


router.post("/:sessionId/share", passport.authenticate("referent", { session: false, failWithError: true }), async (req, res) => {
  try {
    const { error, value } = Joi.object({
      sessionId: Joi.string().required(),
      emails: Joi.array().items(Joi.string().lowercase().trim().email().required()).required().min(1),
    }).validate({ ...req.params, ...req.body }, { stripUnknown: true });


    if (error) {
fork icon4
star icon8
watch icon4

+ 31 other calls in file

200
201
202
203
204
205
206
207
208
209
210
    return apmClient;
}


const validateParameters = (options) => {
    const schema = Joi.object().keys({
        serviceName: Joi.string().required(),
        apmServerUrl: Joi.string().uri().required(),
        secretToken: Joi.string().required(),
        transactionIgnoreUrls: Joi.array()
    }).unknown(true);
fork icon1
star icon5
watch icon2

+ 2 other calls in file

36
37
38
39
40
41
42
43
44
req.body.price = parseInt(req.body.price)
req.body.quantity = parseInt(req.body.quantity)
const Schema = Joi.object({
    name: Joi.string().min(3).max(50).required(),
    price: Joi.number().integer().min(1000).max(1000000000).required(),
    description: Joi.string().min(3).max(10000).required(),
    quantity: Joi.number().integer().min(0).max(1000000).required(),
    finalPaths: Joi.array().items(Joi.string()).required()
})
fork icon0
star icon2
watch icon1