Skip to content

Commit

Permalink
how to use Themis if your schema has no id
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesbowkett committed Feb 21, 2015
1 parent 78ebb0e commit 8ad8ed5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ console.log(require('util').inspect(report, { depth: 10, colors: true }));
// { valid: true, errors: [], subReport: [] }
```

### Validating against schemas with no `id` attribute

Themis assumes your schema will have an `id` giving the schema a name. But if
your schema has no `id` attribute, pass Themis a default `id` of `'0'`.

In the above example, you would change this:

```javascript
// now validate our data against the schema
var report = validator(data, 'basicSchema');
```

to this:

```javascript
// now validate our data against the schema
var report = validator(data, '0');
```

### Validating against multiple schemas
At present themis does not support fetching remote json-schemas. You can however pre-fetch them and pass them in.

Expand Down Expand Up @@ -449,7 +468,7 @@ var validator = Themis.validator(schema, { enable_defaults: true });
var report = validator(empty_data, 'simple_defaults');

console.log(util.inspect(report, { depth: 10, colors: true }));
// { valid: true, errors: [] }
// { valid: true, errors: [], passed: 7 }

console.log(util.inspect(empty_data, { depth: 10, colors: true }));
/*
Expand Down

0 comments on commit 8ad8ed5

Please sign in to comment.