validog
Version:
Dog breed validation library
39 lines (30 loc) • 1.29 kB
Markdown
A simple Javascript and Typescript package to check if a string is a valid dog breed and get breed information.
```
npm install is-valid
```
```js
const { isValidDogBreed, getDogBreedOrigin, getDogBreedData } = require('is-valid');
console.log(isValidDogBreed('Labrador Retriever')); // true
console.log(isValidDogBreed('Unknown Breed')); // false
console.log(getDogBreedOrigin('Labrador Retriever')); // "Canada, United Kingdom (England)"
console.log(getDogBreedData('Affenpinscher'));
// {
// name: 'Affenpinscher',
// origin: 'Germany, France',
// size: 'small',
// temperament: ['confident', 'curious']
// }
```
Returns true if the input string is a valid dog breed, false otherwise.
- Input is normalized (case-insensitive, trimmed)
- Returns false for non-string input
- Supports fuzzy/partial matching and multi-language names
### getDogBreedOrigin(breed: string, options?): string | null
Returns the country/region of origin for a breed, or null if not found.
### getDogBreedData(breed: string, options?): DogBreedData | null
Returns all available data for a breed (name, origin, size, temperament, etc.), or null if not found.