import { array, string, sized } from 'decoders';
// Exactly 3 elements
const rgbDecoder = sized(array(number), { size: 3 });
rgbDecoder.verify([255, 128, 0]); // ✓ OK
rgbDecoder.verify([255, 128]); // Error: size violation
// Minimum length
const atLeastTwoDecoder = sized(array(string), { min: 2 });
atLeastTwoDecoder.verify(['one', 'two', 'three']); // ✓ OK
atLeastTwoDecoder.verify(['one']); // Error: size violation
// Maximum length
const atMostFiveDecoder = sized(array(string), { max: 5 });
atMostFiveDecoder.verify(['a', 'b', 'c']); // ✓ OK
atMostFiveDecoder.verify(['a', 'b', 'c', 'd', 'e', 'f']); // Error: size violation
// Range
const rangeDecoder = sized(array(number), { min: 2, max: 5 });
rangeDecoder.verify([1, 2, 3]); // ✓ OK
rangeDecoder.verify([1]); // Error: size violation
rangeDecoder.verify([1, 2, 3, 4, 5, 6]); // Error: size violation