How to use the freshApi function from tv4

Find comprehensive JavaScript tv4.freshApi code examples handpicked from public code repositorys.

200
201
202
203
204
205
206
207
208
##### freshApi()

Return a new tv4 instance with no shared state.

````
var otherTV4 = tv4.freshApi();
````

##### reset()
fork icon190
star icon0
watch icon34

+ 3 other calls in file

15
16
17
18
19
20
21
22
23
24

```javascript
var tv4 = require('tv4'),
    formats = require('tv4-formats'),
    assert = require('assert'),
    validator = tv4.freshApi(),
    schema = {type: 'string', format: 'date'};

validator.addFormat(formats);
assert(validator.validate('2014-02-11', schema));  // Valid ISO 8601 date
fork icon17
star icon30
watch icon2

+ 3 other calls in file

34
35
36
37
38
39
40
41
42
43
})));

const objects = [];

context.tv4 = context.options.fresh
        ? taskTv4.freshApi()
        : taskTv4;

grunt.util._.each(context.options.schemas, (schema, uri) => {
        context.tv4.addSchema(uri, schema);
fork icon7
star icon13
watch icon1

-4
fork icon4
star icon4
watch icon10

+ 3 other calls in file

10
11
12
13
14
15
16
17
18

function Validator(opts) {
    if (!(this instanceof Validator)) return new Validator(opts);
    var self = this;

    this.tv4 = tv4.freshApi();
    this._opts = util.copy(opts);
    var _schemas = this._opts.schemas = this._opts.schemas || {};
    var _formats = this._opts.formats || {};
fork icon2
star icon4
watch icon1

101
102
103
104
105
106
107
108
109
110
Schema.prototype.loadSchemas = function () {
  Schema.validateSchema(this.__raw__);

  var self = this;

  this.validator = tv.freshApi();
  this.validator.addSchema(this.schemaUri, this.__raw__);

  Object.keys(formats).forEach(function(key) {
    self.validator.addFormat(key, formats[key]);
fork icon1
star icon2
watch icon1

+ 3 other calls in file

15
16
17
18
19
20
21
22
23
24
 * @param {Object} [options={}] options
 * @param {Object} [options.customFormats] custom format validators
 * @param {boolean} [options.banUnknownProperties=false] disallow extra properties in validated objects
 */
constructor(spec, {customFormats, banUnknownProperties} = {}) {
    this.validator = tv4.freshApi()
    this.banUnknowns = banUnknownProperties

    this.validator.addFormat(formats)
    if (customFormats) {
fork icon1
star icon1
watch icon18

+ 3 other calls in file

23
24
25
26
27
28
29
30
31
//this creates "internalAddSchema" to handle the weighty add logic
//need to thoroughly test and modify incoming schema to align with 
//logical schema setup for WIN
addSchemaSupport(self, localConfiguration.metaProperties);

      self.validator = tv4.freshApi();

//config setups
self.multipleErrors = (localConfiguration.multipleErrors == true || localConfiguration.multipleErrors == "true");
fork icon0
star icon0
watch icon2