@@ -5,7 +5,6 @@ import { isValidAddress } from './wallet'
6const hexRegExp = /[0-9A-Fa-f]{64}/g
6const hexRegExp = /[0-9A-Fa-f]{64}/g
9// // Note that this validator also transforms data
8// // Note that this validator also transforms data
10// const validateBase64 = ({ data, pass, error }) => {
9// const validateBase64 = ({ data, pass, error }) => {
11// if (pass !== true) return { data, pass, error }
10// if (pass !== true) return { data, pass, error }
@@ -30,10 +29,6 @@ const hexRegExp = /[0-9A-Fa-f]{64}/g
37// Validates a bip39 mnemonic
32// Validates a bip39 mnemonic
38const validateMnemonic = m => simpleValidatorWrapper({
33const validateMnemonic = m => simpleValidatorWrapper({
39 prevMessage: m,
34 prevMessage: m,
@@ -41,7 +36,6 @@ const validateMnemonic = m => simpleValidatorWrapper({
41 errorMessage: 'This is not a valid mnemonic.'
36 errorMessage: 'This is not a valid mnemonic.'
45// Checks an empty field
39// Checks an empty field
46const validateNotEmpty = m => simpleValidatorWrapper({
40const validateNotEmpty = m => simpleValidatorWrapper({
47 prevMessage: m,
41 prevMessage: m,
@@ -49,8 +43,6 @@ const validateNotEmpty = m => simpleValidatorWrapper({
49 errorMessage: 'This field is required.'
43 errorMessage: 'This field is required.'
54// Checks if a patp is a valid galaxy
46// Checks if a patp is a valid galaxy
55const validateGalaxy = m => simpleValidatorWrapper({
47const validateGalaxy = m => simpleValidatorWrapper({
56 prevMessage: m,
48 prevMessage: m,
@@ -66,8 +58,6 @@ const validateGalaxy = m => simpleValidatorWrapper({
66 errorMessage: 'This is not a valid galaxy'
58 errorMessage: 'This is not a valid galaxy'
71const validatePoint = m => simpleValidatorWrapper({
61const validatePoint = m => simpleValidatorWrapper({
72 prevMessage: m,
62 prevMessage: m,
73 validator: d => {
63 validator: d => {
@@ -80,8 +70,6 @@ const validatePoint = m => simpleValidatorWrapper({
80 errorMessage: 'This is not a valid point'
70 errorMessage: 'This is not a valid point'
85const validateTicket = m => simpleValidatorWrapper({
73const validateTicket = m => simpleValidatorWrapper({
86 prevMessage: m,
74 prevMessage: m,
87 validator: d => {
75 validator: d => {
@@ -94,7 +82,6 @@ const validateTicket = m => simpleValidatorWrapper({
94 errorMessage: 'This is not a valid ticket'
82 errorMessage: 'This is not a valid ticket'
98const validateShard = m => simpleValidatorWrapper({
85const validateShard = m => simpleValidatorWrapper({
99 prevMessage: m,
86 prevMessage: m,
100 validator: d => {
87 validator: d => {
@@ -107,29 +94,24 @@ const validateShard = m => simpleValidatorWrapper({
107 errorMessage: 'This is not a valid shard'
94 errorMessage: 'This is not a valid shard'
111const validateLength = (m, l) => simpleValidatorWrapper({
97const validateLength = (m, l) => simpleValidatorWrapper({
112 prevMessage: m,
98 prevMessage: m,
113 validator: d => d.length === l,
99 validator: d => d.length === l,
114 errorMessage: 'This is of an invalid length'
100 errorMessage: 'This is of an invalid length'
118const validateNetworkKey = m => simpleValidatorWrapper({
103const validateNetworkKey = m => simpleValidatorWrapper({
119 prevMessage: m,
104 prevMessage: m,
120 validator: d => hexRegExp.test(d),
105 validator: d => hexRegExp.test(d),
121 errorMessage: 'This is not a valid network key'
106 errorMessage: 'This is not a valid network key'
125const validateNetworkSeed = m => simpleValidatorWrapper({
109const validateNetworkSeed = m => simpleValidatorWrapper({
126 prevMessage: m,
110 prevMessage: m,
127 validator: d => hexRegExp.test(d),
111 validator: d => hexRegExp.test(d),
128 errorMessage: 'This is not a valid network seed'
112 errorMessage: 'This is not a valid network seed'
133// Checks if a string is a valid ethereum address
115// Checks if a string is a valid ethereum address
134const validateEthereumAddress = m => simpleValidatorWrapper({
116const validateEthereumAddress = m => simpleValidatorWrapper({
135 prevMessage: m,
117 prevMessage: m,
@@ -137,10 +119,6 @@ const validateEthereumAddress = m => simpleValidatorWrapper({
137 errorMessage: 'This is not a valid Ethereum address'
119 errorMessage: 'This is not a valid Ethereum address'
144// Wraps single validation functions in a controlled and predictable way.
122// Wraps single validation functions in a controlled and predictable way.
145const simpleValidatorWrapper = config => {
123const simpleValidatorWrapper = config => {
@@ -172,11 +150,10 @@ const newMessage = (data, pass, error) => ({
178 // validateBase64,
154 // validateBase64,
179 // validateJSON,
155 // validateJSON,
156+ simpleValidatorWrapper,
180 validateMnemonic,
157 validateMnemonic,
181 validateNotEmpty,
158 validateNotEmpty,
182 validateGalaxy,
159 validateGalaxy,