How to use the @xviz/schema.XVIZValidator function in @xviz/schema

To help you get started, we’ve selected a few @xviz/schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / xviz / test / modules / schema / validator.spec.js View on Github external
test('validateGeneric', t => {
  const validator = new XVIZValidator();

  // Straight validate
  validator.validate('primitives/point.schema.json', {points: [[1, 2, 3]]});

  // Normal validation
  validator.validate('primitives/point', {points: [[1, 2, 3]]});

  t.throws(
    () => validator.validate('primitives/point.schema.json', {points: {}}),
    /error/,
    'Should throw validation error'
  );

  t.end();
});
github uber / xviz / test / modules / builder / builders / xviz-metadata-builder.spec.js View on Github external
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* eslint-disable camelcase */
import test from 'tape-catch';
import {Matrix4} from 'math.gl';
import {XVIZMetadataBuilder, XVIZUIBuilder} from '@xviz/builder';
import {XVIZValidator} from '@xviz/schema';

const schemaValidator = new XVIZValidator();

test('XVIZMetadataBuilder#default-ctor', t => {
  const xb = new XVIZMetadataBuilder();
  t.ok(xb, 'Created new XVIZMetadataBuilder');
  t.end();
});

test.skip('XVIZMetadataBuilder#build-with-transformMatrix-array', t => {
  const xb = new XVIZMetadataBuilder();
  xb.startTime(0)
    .endTime(1)
    .stream('/test/stream')
    .category('primitive')
    .type('circle')
    .coordinate('VEHICLE_RELATIVE')
    .transformMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])
github uber / xviz / test / modules / builder / builders / xviz-time-series-builder.spec.js View on Github external
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* eslint-disable camelcase */
import test from 'tape-catch';
import XVIZTimeSeriesBuilder from '@xviz/builder/builders/xviz-time-series-builder';
import {default as XVIZBuilderValidator} from '@xviz/builder/builders/xviz-validator';
import {XVIZValidator} from '@xviz/schema';

const schemaValidator = new XVIZValidator();

const validator = new XVIZBuilderValidator({
  validateWarn: msg => {
    throw new Error(msg);
  },
  validateError: msg => {
    throw new Error(msg);
  }
});

test('XVIZTimeSeriesBuilder#default-ctor', t => {
  /* eslint-disable no-unused-vars */
  const builder = new XVIZTimeSeriesBuilder({});
  t.end();
  /* eslint-enable no-unused-vars */
});
github uber / xviz / test / modules / schema / examples.spec.js View on Github external
function validateFiles(dir, filePaths, t, assert) {
  const validator = new XVIZValidator();

  filePaths = filePaths.map(filePath => path.join(dir, filePath));

  return Promise.all(filePaths.map(loadJSON)).then(jsons => {
    let index = 0;
    for (const data of jsons) {
      const examplePath = filePaths[index];
      const relPath = path.relative(dir, examplePath);
      const directoryPath = path.dirname(relPath);

      // Find the proper schema, using either the directory name of
      // the file name.
      let schemaPath = directoryPath;
      const directPath = relPath.replace('.json', '.schema.json');

      if (!validator.hasSchema(schemaPath)) {
github uber / xviz / test / modules / parser / parsers / parse-xviz-message-sync.spec.js View on Github external
import {XVIZValidator} from '@xviz/schema';

import tape from 'tape-catch';
import clone from 'clone';

import TestMetadataMessageV2 from 'test-data/sample-metadata-message';
import TestMetadataMessageV1 from 'test-data/sample-metadata-message-v1';
import TestFuturesMessageV1 from 'test-data/sample-frame-futures-v1';

import MinimalBinaryMetadata from 'test-data/minimal-metadata';
import MinimalBinaryStateUpdate from 'test-data/minimal-state-update';

import {resetXVIZConfigAndSettings} from '../config/config-utils';
import {TextEncoder} from '@xviz/parser/utils/text-encoding';

const schemaValidator = new XVIZValidator();

// xviz data uses snake_case
/* eslint-disable camelcase */
// Metadata missing normal start_time and end_time
// but with the full log timing fields
const metadataWithLogStartEnd = {
  version: '2.0.0',
  log_info: {
    log_start_time: 1194278450.6,
    log_end_time: 1194278451.6
  },
  streams: {},
  videos: {},
  map_info: {
    map: {
      name: 'phx',
github uber / xviz / test / modules / schema / validator.spec.js View on Github external
test('validateTimeSeries', t => {
  const validator = new XVIZValidator();

  validator.validateTimeSeries({
    timestamp: 12345.5,
    streams: ['/vehicle/torque/commanded', '/vehicle/torque/actual'],
    values: {
      doubles: [5, 4.8]
    }
  });

  t.throws(
    () =>
      validator.validateTimeSeries({
        timestamp: 'foo',
        values: [['/vehicle/torque/commanded', 5], ['/vehicle/torque/actual', 4.8]]
      }),
    /error/,
github uber / xviz / test / modules / schema / validator.spec.js View on Github external
test('validateStreamSet', t => {
  const validator = new XVIZValidator();

  validator.validateStreamSet({timestamp: 1.2, primitives: {}});

  t.throws(() => validator.validateStreamSet({}), /error/, 'Should throw validation error');

  t.end();
});
github uber / xviz / test / modules / schema / validator.spec.js View on Github external
test('validatePose', t => {
  const validator = new XVIZValidator();

  validator.validatePose({
    timestamp: 1001.3,
    map_origin: {
      longitude: 40.4641969,
      latitude: -79.9733218,
      altitude: 219
    },
    position: [238.4, 1002.5, 5.0],
    orientation: [0.5, 10.0, 84.5]
  });

  t.throws(
    () =>
      validator.validatePose({
        timestamp: 1001.3,
github uber / xviz / test / modules / schema / validator.spec.js View on Github external
test('validateVariable', t => {
  const validator = new XVIZValidator();

  validator.validateVariable({
    values: {doubles: [1, 2, 3]}
  });

  t.throws(
    () =>
      validator.validateVariable({
        values: 'bob'
      }),
    /error/,
    'Should not validate'
  );

  t.end();
});