UNPKG

objecture

Version:

❂ Objecture ⏣ Object Watcher, Property Manager ⊚ Capture property changes for object, array mutator methods. ⊚ Schematize and validate object, array properties. ⊚ Browser, NodeJS compatible. ⁘ Uses Core-Plex - Event Listener Manage

20 lines 576 B
import Validator from '../../validator/index.js' export default class EnumValidator extends Validator { constructor($definition = {}, $schema) { super(Object.assign($definition, { type: 'enum', validate: ($key, $value) => { const definition = this.definition let pass if(![ 'string', 'number', 'boolean' ].includes(typeof $value)) { pass = false} else { const enumeration = definition.value pass = enumeration.includes($value) } return pass }, }), $schema) } }