UNPKG

scorm-again

Version:

A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004

43 lines (40 loc) 1.08 kB
import { checkValidFormat, checkValidRange } from "../common/validation"; import { scorm2004_errors } from "../../constants/error_codes"; import { Scorm2004ValidationError } from "../../exceptions/scorm2004_exceptions"; /** * Helper method, no reason to have to pass the same error codes every time * @param {string} value * @param {string} regexPattern * @param {boolean} allowEmptyString * @return {boolean} */ export function check2004ValidFormat( value: string, regexPattern: string, allowEmptyString?: boolean, ): boolean { return checkValidFormat( value, regexPattern, scorm2004_errors.TYPE_MISMATCH, Scorm2004ValidationError, allowEmptyString, ); } /** * Helper method, no reason to have to pass the same error codes every time * @param {string} value * @param {string} rangePattern * @return {boolean} */ export function check2004ValidRange( value: string, rangePattern: string, ): boolean { return checkValidRange( value, rangePattern, scorm2004_errors.VALUE_OUT_OF_RANGE, Scorm2004ValidationError, ); }