Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/validation.js
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | export const isValidTokenInitialQty = (tokenInitialQty, tokenDecimals) => { | ||||
const tokenIntialQtyBig = new BigNumber(tokenInitialQty); | const tokenIntialQtyBig = new BigNumber(tokenInitialQty); | ||||
return ( | return ( | ||||
tokenIntialQtyBig.gte(minimumQty) && | tokenIntialQtyBig.gte(minimumQty) && | ||||
tokenIntialQtyBig.lt(100000000000) && | tokenIntialQtyBig.lt(100000000000) && | ||||
tokenIntialQtyBig.dp() <= tokenDecimals | tokenIntialQtyBig.dp() <= tokenDecimals | ||||
); | ); | ||||
}; | }; | ||||
export const isValidTokenDocumentUrl = tokenDocumentUrl => { | export const isValidTokenDocumentUrl = tokenDocumentUrl => { | ||||
bytesofman: Refactor to match format of other `validatioon.js` functions; do not define a function within a… | |||||
function validURL(str) { | |||||
var pattern = new RegExp( | |||||
'^(https?:\\/\\/)?' + // protocol | |||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name | |||||
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address | |||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path | |||||
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string | |||||
'(\\#[-a-z\\d_]*)?$', | |||||
'i', | |||||
); // fragment locator | |||||
return !!pattern.test(str); | |||||
} | |||||
return ( | return ( | ||||
typeof tokenDocumentUrl === 'string' && | (typeof tokenDocumentUrl === 'string' && | ||||
tokenDocumentUrl.length >= 0 && | tokenDocumentUrl.length >= 0 && | ||||
tokenDocumentUrl.length < 68 | tokenDocumentUrl.length < 68 && | ||||
validURL(tokenDocumentUrl)) || | |||||
tokenDocumentUrl === '' | |||||
); | ); | ||||
}; | }; | ||||
export const isValidTokenStats = tokenStats => { | export const isValidTokenStats = tokenStats => { | ||||
return ( | return ( | ||||
typeof tokenStats === 'object' && | typeof tokenStats === 'object' && | ||||
'timestampUnix' in tokenStats && | 'timestampUnix' in tokenStats && | ||||
'documentUri' in tokenStats && | 'documentUri' in tokenStats && | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |
Refactor to match format of other validatioon.js functions; do not define a function within a validation function, should be simpler