@@ -4,6 +4,7 @@ import { identity, includes } from 'lodash';
5import { isValidAddress } from './wallet';
5import { isValidAddress } from './wallet';
6import patp2dec from './patp2dec';
6import patp2dec from './patp2dec';
7+import { patpStringLength } from './lib';
8// NOTE: do not use the /g modifier for these regexes
9// NOTE: do not use the /g modifier for these regexes
9// https://stackoverflow.com/a/21373261
10// https://stackoverflow.com/a/21373261
@@ -136,19 +137,6 @@ export const validateShard = m =>
136 error: 'This is not a valid shard',
137 error: 'This is not a valid shard',
139−export const validateLength = l => m =>
140− simpleValidatorWrapper({
144− return d.length === l;
149− error: `Must be exactly ${l} characters`,
152export const validateOneOf = (options = []) => m =>
140export const validateOneOf = (options = []) => m =>
153 simpleValidatorWrapper({
141 simpleValidatorWrapper({
154 prevMessage: m,
142 prevMessage: m,
@@ -215,3 +203,37 @@ export const validateExactly = (value, error) => m =>
215 validator: d => d === value,
203 validator: d => d === value,
207+export const validateLength = l => m =>
208+ simpleValidatorWrapper({
212+ return d.length === l;
217+ error: `Must be exactly ${l} characters`,
220+export const validateMaximumLength = l => m =>
221+ simpleValidatorWrapper({
225+ return d.length <= l;
230+ error: `Must be ${l} characters or fewer.`,
233+export const validatePatpByteLength = byteLength => {
234+ return validateLength(patpStringLength(byteLength));
237+export const validateMaximumPatpByteLength = byteLength => {
238+ return validateMaximumLength(patpStringLength(byteLength));