lib/heimdallr-validator.js
function validatePacket(type, packet, fn) {
        debug('Type:', type);
        debug('Packet:', packet);

        if (!tv4.validate(packet, defaultSchemas[type])) {
            return fn(tv4.error);
        }

        if (packet.hasOwnProperty('provider') && !validUUID(packet.provider)) {
            return fn(new Error('`provider` must be a valid UUID'));
        }

        if (packet.hasOwnProperty('t') && !validTimestamp(packet.t)) {
            return fn(new Error('`t` must ba an ISO 8601 timestamp'));
        }

        return fn(null, true);
    }
function validatePacket(type, packet, fn) {
        debug('Type:', type);
        debug('Packet:', packet);

        if (!tv4.validate(packet, defaultSchemas[type])) {
            return fn(tv4.error);
        }

        if (packet.hasOwnProperty('provider') && !validUUID(packet.provider)) {
            return fn(new Error('`provider` must be a valid UUID'));
        }

        if (packet.hasOwnProperty('t') && !validTimestamp(packet.t)) {
            return fn(new Error('`t` must ba an ISO 8601 timestamp'));
        }

        return fn(null, true);
    }
function validatePacket ( type , packet , fn ) { debug ( 'Type:' , type ) ; debug ( 'Packet:' , packet ) ; if ( ! tv4 . validate ( packet , defaultSchemas [ type ] ) ) { return fn ( tv4 . error ) ; } if ( packet . hasOwnProperty ( 'provider' ) && ! validUUID ( packet . provider ) ) { return fn ( new Error ( '`provider` must be a valid UUID' ) ) ; } if ( packet . hasOwnProperty ( 't' ) && ! validTimestamp ( packet . t ) ) { return fn ( new Error ( '`t` must ba an ISO 8601 timestamp' ) ) ; } return fn ( null , true ) ; }
Verifies that the packet conforms to the correct structure for the
given type. It first checks if the packet violates the schema for
the type then if there is a provider field and it is not a valid UUID
then if there is a t field and it is not a valid ISO 8601 timestamp.

@arg {string} type - The type of Heimdallr packet. Must be
'event', 'sensor', or 'control'.
@arg {object} packet - The packet to validate.
@arg {function} fn - Node-style callback that will be passed an error
as the first argument if the packet is invalid.
Verifies that the packet conforms to the correct structure for the given type . It first checks if the packet violates the schema for the type then if there is a provider field and it is not a valid UUID then if there is a t field and it is not a valid ISO 8601 timestamp .