zcash-grant-system/frontend/client/utils/validators.ts

24 lines
639 B
TypeScript
Raw Normal View History

2018-09-10 09:55:26 -07:00
export function getAmountError(amount: number, max: number = Infinity) {
if (amount < 0) {
return 'Amount must be a positive number';
} else if (
amount.toFixed(3).length < amount.toString().length ||
amount.toString().includes('1e')
) {
return 'Must be in increments of 0.001';
} else if (amount > max) {
2018-12-27 09:41:26 -08:00
return `Cannot exceed maximum (${max} ZEC)`;
2018-09-10 09:55:26 -07:00
}
return null;
}
2018-11-09 11:54:04 -08:00
export function isValidEmail(email: string): boolean {
return /\S+@\S+\.\S+/.test(email);
}
2018-12-14 11:36:22 -08:00
export function isValidAddress(address: string): boolean {
console.warn('TODO - implement utils.isValidAddress', address);
return true;
}