<commit_before>var expect = require('expect.js');
var s = require('../src/iterator');
var newValidator = s.newValidator;

describe("validator", function() {

    var Ok = {valid: true, errors: []};
    function FailWith() {
        return {valid: false, errors: [].slice.call(arguments)};
    }

    function validate(schema, value, exp, opts, whatToReturn) {
        opts = opts || {};
        //opts.noinline = true;
        var it = newValidator(schema, opts);
        //console.log(it.fn.toString());
        var res = it(value);
        res.errors = res.errors.map(function(e) { return e[whatToReturn || 'code']; });
        expect({value: value, validationResult: res}).to.eql({value: value, validationResult: exp});
    }

    function schema(schema, options) {
        var o = options;
        return {
            withFormat: function(fmt) {
                o = o || {formats: {}};
                o.formats[fmt.name] = fmt;
                return this;
            },
            withCustom: function(name, cst) {
                o = o || {custom: {}};
                o.custom[name] = cst;
                return this;
            },
            validate: function(value, exp, whatToReturn) {
                validate(schema, value, exp, o, whatToReturn);
                return this;
            },
            validatePath: function(value, exp) {
                validate(schema, value, exp, o, "path");<commit_msg>restore tests options<commit_after>var expect = require('expect.js');
var s = require('../src/iterator');
var newValidator = s.newValidator;

describe("validator", function() {

    var Ok = {valid: true, errors: []};
    function FailWith() {
        return {valid: false, errors: [].slice.call(arguments)};
    }

    function validate(schema, value, exp, opts, whatToReturn) {
        opts = opts || {};
        opts.noinline = true;
        var it = newValidator(schema, opts);
        var res = it(value);
        res.errors = res.errors.map(function(e) { return e[whatToReturn || 'code']; });
        expect({value: value, validationResult: res}).to.eql({value: value, validationResult: exp});
    }

    function schema(schema, options) {
        var o = options;
        return {
            withFormat: function(fmt) {
                o = o || {formats: {}};
                o.formats[fmt.name] = fmt;
                return this;
            },
            withCustom: function(name, cst) {
                o = o || {custom: {}};
                o.custom[name] = cst;
                return this;
            },
            validate: function(value, exp, whatToReturn) {
                validate(schema, value, exp, o, whatToReturn);
                return this;
            },
            validatePath: function(value, exp) {
                validate(schema, value, exp, o, "path");
{'fraction_non_alphanumeric': 0.14392059553349876, 'fraction_numerical': 0.0, 'mean_word_length': 1.8884339815762539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2189700', 'n_tokens_mistral': 803, 'n_tokens_neox': 780, 'n_words': 196}