Rocky_Mountain_Vending/.pnpm-store/v10/files/ae/8737fc2c2f7b70771ee676a767e8f1dc8b6b120718dd3c59feadae1a7fb19ce89eafcc204c01d7b49fafe3c1857a354627b08cec6e983c9bd5e5200d532fca-exec
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

100 lines
2.5 KiB
Text
Executable file

'use strict';
const { assert } = require('@hapi/hoek');
const Any = require('./any');
const Common = require('../common');
const internals = {};
module.exports = Any.extend({
type: 'binary',
coerce: {
from: ['string', 'object'],
method(value, { schema }) {
if (typeof value === 'string' || (value !== null && value.type === 'Buffer')) {
try {
return { value: Buffer.from(value, schema._flags.encoding) };
}
catch { }
}
}
},
validate(value, { error }) {
if (!Buffer.isBuffer(value)) {
return { value, errors: error('binary.base') };
}
},
rules: {
encoding: {
method(encoding) {
assert(Buffer.isEncoding(encoding), 'Invalid encoding:', encoding);
return this.$_setFlag('encoding', encoding);
}
},
length: {
method(limit) {
return this.$_addRule({ name: 'length', method: 'length', args: { limit }, operator: '=' });
},
validate(value, helpers, { limit }, { name, operator, args }) {
if (Common.compare(value.length, limit, operator)) {
return value;
}
return helpers.error('binary.' + name, { limit: args.limit, value });
},
args: [
{
name: 'limit',
ref: true,
assert: Common.limit,
message: 'must be a positive integer'
}
]
},
max: {
method(limit) {
return this.$_addRule({ name: 'max', method: 'length', args: { limit }, operator: '<=' });
}
},
min: {
method(limit) {
return this.$_addRule({ name: 'min', method: 'length', args: { limit }, operator: '>=' });
}
}
},
cast: {
string: {
from: (value) => Buffer.isBuffer(value),
to(value, helpers) {
return value.toString();
}
}
},
messages: {
'binary.base': '{{#label}} must be a buffer or a string',
'binary.length': '{{#label}} must be {{#limit}} bytes',
'binary.max': '{{#label}} must be less than or equal to {{#limit}} bytes',
'binary.min': '{{#label}} must be at least {{#limit}} bytes'
}
});