This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = [{ | |
method : 'GET', | |
url : '/checkNumbers', | |
handler : async (req, reply) => ({ message : 'Yay! Success!, success : true }), | |
schema : { | |
querystring : { | |
type : 'object', | |
properties : { | |
positive_number : { | |
type : 'number', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 3. | |
const isGeoLocation = [ | |
function validate(data) { | |
const inRange = (number, min, max) => number >= min && number <= max; | |
const [ lat, lng ] = data.split(','); | |
return inRange(Number(lat), -90, 90) && inRange(Number(lng), -180, 180); | |
}, | |
function errorMessage(schema, parentSchema, data) { | |
return `${data} is not a valid geolocation point. [lat,lng] format is required.` | |
}, |