/*global Web3*/
import React from 'react';
import {Form} from 'react-bootstrap';
export const required = (value) => {
if (!value.toString().trim().length) {
return
This field is required;
}
};
export const isInteger = (value) => {
value = parseFloat(value);
if (!Number.isInteger(value)) {
return This field needs to be an integer;
}
};
export const isNumber = (value) => {
if (Number.isNaN(value)) {
return This field needs to be an number;
}
};
export const lowerThan = (max, value) => {
if (value >= max) {
return This field needs to be lower than {max};
}
};
export const lowerEqThan = (max, value) => {
if (value > max) {
return This field needs to be lower or equal than {max};
}
};
export const higherThan = (min, value) => {
if (value <= min) {
return This field needs to be higher than {min};
}
};
export const higherEqThan = (min, value) => {
if (value < min) {
return This field needs to be higher or equal than {min};
}
};
export const isAddress = (value) => {
if (!Web3.utils.isAddress(value)) {
return This field needs to be a valid Ethereum address;
}
};
export const isJSON = (value) => {
try {
JSON.parse(value);
} catch (e) {
return This field needs to be a valid JSON string;
}
};