fixed issue regarding coordinate validation and logic for query
This commit is contained in:
parent
dfa1c93450
commit
d9f6e3a928
|
|
@ -15,7 +15,7 @@ import {
|
||||||
sendOkResponse,
|
sendOkResponse,
|
||||||
sendResponseNoContent,
|
sendResponseNoContent,
|
||||||
} from '../utils/responses.js'
|
} from '../utils/responses.js'
|
||||||
import { integer, uuid, varChar } from '../validators/expressValidator/customValidators.js'
|
import { integer, latitudeRange, longitudeRange, uuid, varChar } from '../validators/expressValidator/customValidators.js'
|
||||||
import { integerRange } from '../validators/expressValidator/customValidators.js'
|
import { integerRange } from '../validators/expressValidator/customValidators.js'
|
||||||
import {payloadExpressValidator} from '../validators/expressValidator/payloadExpressValidator.js'
|
import {payloadExpressValidator} from '../validators/expressValidator/payloadExpressValidator.js'
|
||||||
import { authorizePermission, setToken, authenticateToken, refreshAuthenticate} from '../middlewares/auth.js'
|
import { authorizePermission, setToken, authenticateToken, refreshAuthenticate} from '../middlewares/auth.js'
|
||||||
|
|
@ -896,7 +896,8 @@ export default(config) => {
|
||||||
varChar('name').optional({ nullable: false, values: 'falsy' }),
|
varChar('name').optional({ nullable: false, values: 'falsy' }),
|
||||||
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
||||||
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
||||||
uuid('fk_coordinate').optional({ nullable: false, values: 'falsy' }),
|
latitudeRange('latitude').optional({ nullable: false, values: 'falsy' }),
|
||||||
|
longitudeRange('longitude').optional({nullable: false, values: 'falsy'})
|
||||||
],
|
],
|
||||||
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
||||||
(req, res, next) => getPlaceListController(req, res, next, config),
|
(req, res, next) => getPlaceListController(req, res, next, config),
|
||||||
|
|
@ -931,7 +932,8 @@ export default(config) => {
|
||||||
varChar('name').optional({ nullable: false, values: 'falsy' }),
|
varChar('name').optional({ nullable: false, values: 'falsy' }),
|
||||||
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
||||||
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
||||||
uuid('fk_coordinate').optional({ nullable: false, values: 'falsy' }),
|
latitudeRange('latitude').optional({ nullable: false, values: 'falsy' }),
|
||||||
|
longitudeRange('longitude').optional({nullable: false, values: 'falsy'})
|
||||||
],
|
],
|
||||||
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
||||||
(req, res, next) => getPlaceByUuidController(req, res, next, config),
|
(req, res, next) => getPlaceByUuidController(req, res, next, config),
|
||||||
|
|
@ -964,7 +966,8 @@ export default(config) => {
|
||||||
varChar('name'),
|
varChar('name'),
|
||||||
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
||||||
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
||||||
uuid('fk_coordinate')
|
latitudeRange('latitude'),
|
||||||
|
longitudeRange('longitude')
|
||||||
],
|
],
|
||||||
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
||||||
(req, res, next) => insertPlaceController(req, res, next, config),
|
(req, res, next) => insertPlaceController(req, res, next, config),
|
||||||
|
|
@ -999,7 +1002,8 @@ export default(config) => {
|
||||||
varChar('name').optional({ nullable: false, values: 'falsy' }),
|
varChar('name').optional({ nullable: false, values: 'falsy' }),
|
||||||
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
varChar('address').optional({ nullable: true, values: 'falsy' }),
|
||||||
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
varChar('description').optional({ nullable: true, values: 'falsy' }),
|
||||||
uuid('fk_coordinate').optional({ nullable: false, values: 'falsy' }),
|
latitudeRange('latitude').optional({ nullable: false, values: 'falsy' }),
|
||||||
|
longitudeRange('longitude').optional({nullable: false, values: 'falsy'})
|
||||||
],
|
],
|
||||||
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
(req, res, next) => payloadExpressValidator(req, res, next, config),
|
||||||
(req, res, next) => modifyPlaceController(req, res, next, config),
|
(req, res, next) => modifyPlaceController(req, res, next, config),
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,22 @@ const integer = field => check(field).isInt({min: Number.MIN_SAFE_INTEGER, max:
|
||||||
const integerRange = (field, { min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER } = {}) => check(field).isInt({min, max}).withMessage(`|${field}| must be an integer between ${min} and ${max}`)
|
const integerRange = (field, { min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER } = {}) => check(field).isInt({min, max}).withMessage(`|${field}| must be an integer between ${min} and ${max}`)
|
||||||
const uuid = field => check(field).isUUID('all').withMessage(`|${field}| must be a valid UUID`)
|
const uuid = field => check(field).isUUID('all').withMessage(`|${field}| must be a valid UUID`)
|
||||||
const bigInt = field => check(field).isBigInt().withMessage(`|${field}| must be a valid BigInt`)
|
const bigInt = field => check(field).isBigInt().withMessage(`|${field}| must be a valid BigInt`)
|
||||||
|
const longitudeRange = (field, { min = -180, max = 180 } = {}) =>
|
||||||
|
check(field)
|
||||||
|
.isFloat({ min, max })
|
||||||
|
.withMessage(`|${field}| must be a number between ${min} and ${max}`)
|
||||||
|
|
||||||
|
const latitudeRange = (field, { min = -90, max = 90 } = {}) =>
|
||||||
|
check(field)
|
||||||
|
.isFloat({ min, max })
|
||||||
|
.withMessage(`|${field}| must be a number between ${min} and ${max}`)
|
||||||
|
|
||||||
export {
|
export {
|
||||||
integer,
|
integer,
|
||||||
integerRange,
|
integerRange,
|
||||||
uuid,
|
uuid,
|
||||||
varChar,
|
varChar,
|
||||||
bigInt
|
bigInt,
|
||||||
|
latitudeRange,
|
||||||
|
longitudeRange
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue