{"id":47706,"library":"form-schema-validation","title":"form-schema-validation","description":"A schema-based object validation library for JavaScript, currently at version 2.0.1. It provides synchronous and asynchronous (Promise-based) validation, supports custom types, one-of type validation, custom validators, and nested schema definitions. Features include validating required/optional fields, object structure, keys, and custom error messages. It is commonly used for form validation but can validate any object. The library offers a simple API with a Schema class and validate method, and allows control over key validation via the validateKeys flag. It is maintained intermittently with low release cadence.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/rstgroup/form-schema-validation","tags":["javascript","schema","form","forms","object","validation","validation-schema","schema-validation","js-schema"],"install":[{"cmd":"npm install form-schema-validation","lang":"bash","label":"npm"},{"cmd":"yarn add form-schema-validation","lang":"bash","label":"yarn"},{"cmd":"pnpm add form-schema-validation","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export. Works with ES modules and CommonJS via bundlers.","wrong":"const Schema = require('form-schema-validation')","symbol":"Schema","correct":"import Schema from 'form-schema-validation'"},{"note":"CustomValidator is a TypeScript type, not a runtime value. Use import type for TypeScript.","wrong":"import { CustomValidator } from 'form-schema-validation'","symbol":"CustomValidator type","correct":"import type { CustomValidator } from 'form-schema-validation'"},{"note":"Check documentation for exported types; not all types may be exported.","wrong":"","symbol":"SchemaOptions type (if available)","correct":"import type { SchemaOptions } from 'form-schema-validation'"}],"quickstart":{"code":"import Schema from 'form-schema-validation';\n\nconst schema = new Schema({\n    name: { type: String, required: true },\n    age: { type: Number, required: true, min: 0 },\n});\n\nconst model = { name: 'Alice', age: 30 };\nconst errors = schema.validate(model);\nif (Object.keys(errors).length === 0) {\n    console.log('Valid!');\n} else {\n    console.log('Errors:', errors);\n}","lang":"javascript","description":"Shows basic synchronous validation: define schema with type and required constraints, validate an object, and check for errors."},"warnings":[{"fix":"Ensure the model argument is an object before calling validate().","message":"If the model object is null or undefined, validate() may throw an error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"const errors = await schema.validate(model);","message":"When using async validators, validate() returns a Promise. Use then/catch or async/await.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Set { validateKeys: false } in constructor options to allow extra keys.","message":"The validateKeys option (set in constructor) determines whether keys not in schema cause errors. Default is true, meaning extra keys will produce errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.0.1':17 'allow':79 'api':70 'asynchron':22 'base':8,25 'cadenc':95 'class':74 'common':55 'control':80 'current':14 'custom':28,35,50 'definit':40 'error':51 'featur':41 'field':45 'flag':87 'form':2,58,98,99 'form-schema-valid':1 'includ':42 'intermitt':91 'javascript':13,96 'js':109 'js-schema':108 'key':48,82 'librari':11,66 'low':93 'maintain':90 'messag':52 'method':77 'nest':38 'object':9,46,64,100 'offer':67 'one':31 'one-of':30 'promis':24 'promise-bas':23 'provid':19 'releas':94 'required/optional':44 'schema':3,7,39,73,97,104,106,110 'schema-bas':6 'schema-valid':105 'simpl':69 'structur':47 'support':27 'synchron':20 'type':29,33 'use':56 'valid':4,10,26,34,36,43,59,62,76,83,101,103,107 'validatekey':86 'validation-schema':102 'version':16 'via':84","created_at":"2026-06-07T16:52:53.369842+00:00","updated_at":"2026-06-07T16:52:53.369842+00:00","problems":[{"fix":"Ensure all schema fields are defined or use optional chaining.","cause":"Passing an undefined or null field in schema definition that is accessed during validation.","error":"TypeError: Cannot read property 'type' of undefined"},{"fix":"Handle the promise returned by validate() and catch errors.","cause":"An async validator threw an error or returned a rejected promise.","error":"Unhandled promise rejection: ValidationError: async test error"},{"fix":"Coerce or convert the model value to match the schema type.","cause":"Type mismatch: field type in schema is String but model value is a number.","error":"Expected string but got number"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/rstgroup/form-schema-validation","github":"https://github.com/rstgroup/form-schema-validation","docs":null,"changelog":null,"pypi":null,"npm":"form-schema-validation","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}