Commit 0681e185 authored by Stefan Cameron's avatar Stefan Cameron

Progressing but need to make BIG change to Array

In the full notation, the typeset for the array
elements must be moved into args so that calling
the isArray() validator can behave the same as
isMap() and call impl.check() on the typeset
for each element in the array. This is the
same as CLASS_OBJECT's validator which will
need to get the shape from args and check
each own-property...
parent 9e7b65ed
......@@ -473,6 +473,11 @@ const checkWithArray = function(value, typeset /*, options*/) {
}
break; // break (since this must be the last element in typeset)
} else if (isArray(subtype[0]) || subtype[0] === types.ARRAY) {
// subtype is a nested Array typeset
// DEBUG TODO: need to call checkWithType(value, subtype) and that method should handle
// an array as its second parameter as representing a single type with possible
// qualifier and args, and pass that onto the appropriate validator...
} else {
console.log('===== calling check, typesetCopy=%s, idx=%s, subtype=%s, value=%s', print(typesetCopy), idx, print(subtype), print(value)); // DEBUG
const result = check(value, subtype, _getCheckOptions(options, {
......
......@@ -7,6 +7,8 @@ import isFinite from './isFinite';
import types from '../types';
import qualifiers from '../qualifiers';
let impl; // @type {rtvref.impl}
/**
* Type: {@link rtvref.types.ARRAY ARRAY}
* @const {string} rtvref.validator.isArray.type
......@@ -19,6 +21,7 @@ export const type = types.ARRAY;
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
impl = settings.impl;
};
/**
......
......@@ -285,10 +285,10 @@ describe.only('module: lib/impl', function() { // DEBUG remove only
});
describe.only('#check()', function() { // DEBUG remove only
it('should return an RtvSuccess on successful validation', function() {
expect(impl.check(1, types.FINITE)).to.be.an.instanceof(RtvSuccess);
expect(impl.check(1, function() { return true; })).to.be.an.instanceof(RtvSuccess);
expect(impl.check({foo: 'bar'}, {foo: types.STRING})).to.be.an.instanceof(RtvSuccess);
it.only('should return an RtvSuccess on successful validation', function() {
// expect(impl.check(1, types.FINITE)).to.be.an.instanceof(RtvSuccess);
// expect(impl.check(1, function() { return true; })).to.be.an.instanceof(RtvSuccess);
// expect(impl.check({foo: 'bar'}, {foo: types.STRING})).to.be.an.instanceof(RtvSuccess);
expect(impl.check(1, [types.FINITE])).to.be.an.instanceof(RtvSuccess);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment