utils/validations

Validation function for the Chords API.
Description:
  • Validation function for the Chords API.
Source:

Methods

(static) calculateValidChords() → {Array}

Description:
  • Function to calculate valid chord Ids It combines all valid notes with all valid chord types to create a list of valid chord Ids.
Source:
Returns:
- An array of valid chord Ids.
Type
Array

(static) isValidChordId(chordId) → {Boolean}

Description:
  • Validate chord id This function checks if the provided chordId is valid by comparing it against a list of valid chords.
Source:
Parameters:
Name Type Description
chordId String The chord Id to validate.
Returns:
- Returns true if the chordId is valid, false if not.
Type
Boolean

(static) isValidChordTypeId(typeId) → {Boolean}

Description:
  • Validate chord type id This function checks if the provided typeId is valid by comparing it against a list of valid chords types.
Source:
Parameters:
Name Type Description
typeId String The chord type Id to validate.
Returns:
- Returns true if the typeId is valid, false if not.
Type
Boolean

(static) isValidLimit(limit) → {Boolean}

Description:
  • Validate limit (number or strnig 'all') This function checks if the provided 'limit' is a number, 0 or 'all'.
Source:
Parameters:
Name Type Description
limit String | Number The limit parameter to validate.
Returns:
- Returns true if the limit is valid, false if not.
Type
Boolean

(static) isValidNoteId(noteId) → {Boolean}

Description:
  • Validate note id This function checks if the provided noteId is valid by comparing it against a list of valid notes.
Source:
Parameters:
Name Type Description
noteId String The note Id to validate.
Returns:
- Returns true if the noteId is valid, false if not.
Type
Boolean

(static) isValidPage(page) → {Boolean}

Description:
  • Validate page (number) This function checks if the provided 'page' is a correct number.
Source:
Parameters:
Name Type Description
page Number The "page" parameter to validate.
Returns:
- Returns true if the page is valid, false if not.
Type
Boolean

(static) validateChordParam(chordId) → {Array}

Description:
  • Validate chord id path parameter
Source:
Parameters:
Name Type Description
chordId String The chordId parameter to validate.
Returns:
- Returns an array with a boolean indicating if the validation passed and a message if it failed.
Type
Array

(static) validateChordTypeParam(chordTypeId) → {Array}

Description:
  • Validate chord type id path parameter
Source:
Parameters:
Name Type Description
chordTypeId String The chordTypeId path parameter to validate.
Returns:
- Returns an array with a boolean indicating if the validation passed and a message if it failed.
Type
Array

(static) validateQueries(note, type, limit, page) → {Array}

Description:
  • Validates all query parameters
Source:
Parameters:
Name Type Description
note String The note query parameter to validate.
type String The type query parameter to validate.
limit String | Number The limit query parameter to validate.
page Number The page query parameter to validate.
Returns:
- Returns an array with a boolean indicating if the validation passed and a message if it failed.
Type
Array