Skip to content

Commit

Permalink
Added validation for numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Jan 22, 2020
1 parent 7c2e1dc commit 98bd714
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Joi from 'joi';
export const querySignalsSchema = Joi.object({
query: Joi.object(),
aggs: Joi.object(),
size: Joi.number(),
size: Joi.number().integer(),
track_total_hits: Joi.boolean(),
_source: Joi.array().items(Joi.string()),
}).min(1);
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ export const timeline_title = Joi.string().when('timeline_id', {
otherwise: Joi.forbidden(),
});
export const meta = Joi.object();
export const max_signals = Joi.number().greater(0);
export const max_signals = Joi.number()
.integer()
.greater(0);
export const name = Joi.string();
export const risk_score = Joi.number()
.integer()
.greater(-1)
.less(101);
export const severity = Joi.string().valid('low', 'medium', 'high', 'critical');
Expand All @@ -51,9 +54,11 @@ export const references = Joi.array()
.items(Joi.string())
.single();
export const per_page = Joi.number()
.integer()
.min(0)
.default(20);
export const page = Joi.number()
.integer()
.min(1)
.default(1);
export const signal_ids = Joi.array().items(Joi.string());
Expand Down Expand Up @@ -97,4 +102,6 @@ export const updated_at = Joi.string()
.strict();
export const created_by = Joi.string();
export const updated_by = Joi.string();
export const version = Joi.number().min(1);
export const version = Joi.number()
.integer()
.min(1);

0 comments on commit 98bd714

Please sign in to comment.