UNPKG

@yobta/validator

Version:
9 lines (8 loc) 341 B
import { rule } from '../rule/rule.js'; export const identicalMessage = (field, path) => `"${field}" should be identical to "${path}"`; export const identical = (path, message = identicalMessage) => rule((input, { data, field }) => { if (input === data[path]) { return input; } throw new Error(message(field, path)); });