New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

uss-validator

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uss-validator

Provides validation for Universal Schedule Standard (.uss) objects

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Universal Schedule Standard Validator

GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests License: MIT

Provides validation for Universal Schedule Standard objects.

This package may be used either on the frontend or backend. Is is written in ECMA Script 5, so it is widely compatible with any Javascript project.

Install

Navigate to your project folder and enter the following in terminal:

npm install uss-validator

The uss-validator will be added into your project and your package.json file.

How to Use

You call the validator with a Universal Schedule Standard Object as the only argument. The validator accepts Universal Schedule Standard objects as either JSON strings or JSON objects.

import validator from 'uss-validator'

// then get get a .uss file or an object

const universalScheduleStandardObject = JSON.parse(file)
const response = validator(universalScheduleStandardObject)

console.log(response)

It will return a response object.

Response Object

The response object has four primary key values: isValid, errors, warnings and info.

{  
  isValid: true,
  errors: [],
  warnings: [
    { 
      title: 'Stripboard missing Calendar', 
      location: ['5d01230c987033001725c908'],
      message: 'There is a stripboard that is missing its calendarId'
    }
  ],
  info: { 
    isSchedule: true,
    name: 'Small Sample Schedule',
    source: 'Think Crew',
    ussVersion: '1.0.0',
    breakdowns: 3,
    categories: 5,
    elements: 6,
    stripboards: 2,
    calendars: 1
  }
}

The isValid value is a boolean that denotes whether the USS object is considered to be a valid construction.

The errors and warnings values are arrays that may contain error objects that describe any issues with the USS object. Errors are considered fatal and always result in isValid returning false. Warnings are merely related to the user's data potentially being malformed, and are not fatal.

The info object contains various pieces of information about the USS object:

KeyValue
isScheduleboolean | true if the USS object contains both stripboard and calendar data
namestring | the name of the schedule
sourcestring | the originating site or app
ussVersionstring | the version of the standard this file is using
breakdownsnumber | the number of breakdowns in the object
categoriesnumber | the number of categories in the object
elementsnumber | the number of elements in the object
stripboardsnumber | the number of stripboards in the object
calendarsnumber | the number of calendars in the object

Error Objects

The uss-validator will return errors or warnings in the following format:

{
  title: string | the title of the error or warning,
  message: string | the full error or warning message,
  location: array | an array of text strings that will give clues as to where the error occurred in the file
}

Errors and warnings use the same object construction.

Keywords

validation

FAQs

Package last updated on 22 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts