An open API service indexing awesome lists of open source software.

https://github.com/allemandi/bible-validate

Fast, type-safe utilities for parsing, validating, and normalizing Bible references.
https://github.com/allemandi/bible-validate

bible bible-api bible-books bible-format bible-parser bible-reference bible-utils bible-validation chapter-verse commonjs esm reference-parser scripture umd

Last synced: 14 days ago
JSON representation

Fast, type-safe utilities for parsing, validating, and normalizing Bible references.

Awesome Lists containing this project

README

          

# ๐Ÿ“– @allemandi/bible-validate

[![NPM Version](https://img.shields.io/npm/v/@allemandi/bible-validate)](https://www.npmjs.com/package/@allemandi/bible-validate)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/allemandi/bible-validate/blob/main/LICENSE)

> **Fast, type-safe utilities for parsing, validating, and normalizing Bible references.**
>
> Works in Node.js, browsers โ€“ supports ESM, CommonJS, UMD, and TypeScript.

## ๐Ÿ”– Table of Contents

- [โœจ Features](#-features)
- [๐Ÿ› ๏ธ Installation](#๏ธ-installation)
- [๐Ÿš€ Quick Usage Examples](#-quick-usage-examples)
- [๐Ÿงช Tests](#-tests)
- [๐Ÿค Contributing](#-contributing)

## โœจ Features

- Validate Bible book names and aliases
- Get chapter and verse counts
- Normalize references (e.g. `"III John Chapter 1 verses 3 - 8"` to `"3 John 1:3-8"`)
- Validate full references (book, chapter, verse range)
- Parse and format Bible references with optional structured output

## ๐Ÿ› ๏ธ Installation

```bash
# Yarn
yarn add @allemandi/bible-validate

# or NPM
npm install @allemandi/bible-validate
```

## ๐Ÿš€ Quick Usage Examples

> ๐Ÿ“˜ For a complete list of methods and options, see [the API docs](https://github.com/allemandi/bible-validate/blob/main/docs/API.md).

**ESM**

```js
import { parseAndValidateReference, isValidBook, getChapterCount } from '@allemandi/bible-validate';
const ref = 'GeN Chapter 3: 16 to 18';
const result = parseAndValidateReference(ref, { structured: true });
console.log(result);
// {
// isValid: true,
// book: 'Genesis',
// chapter: 3,
// verseStart: 16,
// verseEnd: 18,
// formatted: 'Genesis 3:16-18',
// error: null,
// original: 'GeN Chapter 3: 16 to 18'
// }

// Check book validity
console.log(isValidBook('Second Chronicles')); // true

// Get verse count for specific chapter in a book
console.log(getVerseCount('Rev', 3)); // 22
```

**CommonJS**

```js
const { parseAndValidateReference } = require('@allemandi/bible-validate');
```

**UMD (Browser)**

```bash

const result = window.bibleValidate.parseAndValidateReference('John 3:16');
console.log(result);

```

## ๐Ÿงช Tests

> Available in the GitHub repo only.

```bash
# Run the test suite with Jest
yarn test
# or
npm test
```

## ๐Ÿค Contributing

If you have ideas, improvements, or new features:

1. Fork the project
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature)
5. Open a Pull Request