Sha256: 01b7214b70c4a80a7126c07e56813b25f3777496360d0548ebe7f7e3351dfc7b

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

import {
    isEq,
    isArray,
    getError,
    validateByShema,
    ifElse,
    prop,
    isBase64,
    validatePipe,
    isRequired,
    isValidDataPair,
    pipe
} from './validators'

const customDataV1Scheme = {
    version: isEq(1),
    binary: isBase64,
}

const customDataV2Scheme = {
    version: isEq(2),
    data: validatePipe(
        isArray,
        (data: Array<unknown>) => data.every(
            validatePipe(
                isRequired(true),
                isValidDataPair
            )
        )
    ),
}

const v1Validator = validateByShema(customDataV1Scheme, getError)
const v2Validator = validateByShema(customDataV2Scheme, getError)

export const customDataValidator = ifElse(
    pipe(prop('version'), isEq(1)),
    v1Validator, 
    v2Validator
)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/waves-transactions/src/validators/custom-data.ts