
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@ephox/boulder
Advanced tools
Boulder is a project designed to provide a nice syntax for validating JavaScript objects. The purpose of it is to provide useful feedback for when a developer has not specified an object correctly. Another purpose of it is to sensibly handle defaulting of arguments and optional arguments.
The API exposed by boulder will be constantly changing, but it should always be based on structure and field schemas. Structure schemas are used to represent an entire structure of fields (e.g. number, array, object etc.). Field schemas are used to represent a single field inside an object (e.g. object.alpha). By combining them, boulder should be able to specify objects of reasonable complexity.
boulder is available as an npm package. You can install it via the npm package @ephox/boulder
npm install @ephox/boulder
boulder uses bedrock to run tests. The tests are run through the test script in the project. Specifically,
$ yarn test
ephox.boulder.api.StructureSchema
setOf :: (JsObj -> Result, StructureProcessor) -> StructureProcessor
thunkOf :: (String, () -> StructureProcessor) -> StructureProcessor
funcOrDie :: (Array, () -> StructureProcessor) -> StructureProcessor
asRaw :: (String, StructureProcessor, JsObj) -> Result (JsObj)
ephox.boulder.api.FieldSchema
field :: (String, String, Presence, StructureProcessor) -> FieldSchemacustomField :: (String, (JsObj -> JsObj)) -> FieldSchemaephox.boulder.api.ValueType
anyValue :: () -> StructureProcessornumber :: () -> StructureProcessorstring :: () -> StructureProcessorboolean :: () -> StructureProcessorfunc :: () -> StructureProcessorpostMessageable :: () -> StructureProcessorNote, there are many other APIs as well, but they tend to be convenience functions built on top of these constructors.
validator, which will take the value as an argument and return Result.value if it should be allowed, and Result.error if it should not. Result is a data type defined by katamari.schema.fieldSchemas. Note, the object can have more fields that those defined in the schema, and if some of the field schemas are defaulted or optional, they may not be necessary.validator, but you don't actually know their exact names. The schema is used to match the value of every field. This is useful for sitautions where a server might be responding with an object where each key matching some id of something else and isn't known in advance.description is used to give a simple description of what this schema is representing, because trying to invoke it when calculating the DSL can cause an infinite loop. The schemaThunk is a function that takes no arguments, and returns the StructureSchema to use.pork belly filet mignon jerky meatloaf sirloin ground round corned beef prosciutto chicken pig venison capicola. Pork belly ball tip leberkas doner, kevin jerky turkey chicken ham bacon. Ribeye shankle short loin, pastrami pork chop filet mignon drumstick t-bone picanha.schema for an object and an object (obj), and return a [structified]((https://www.npmjs.com/package/@ephox/katamari) version of the object in a Result.value if it matches the schema. If it does not match, returns Result.error with the validation errors. A struct is just an object where every property is wrapped in an accessor function.schema for an object and an object (obj), and return a plain version of the object in a Result.value if it matches the schema. If it does not match, returns Result.error with the validation errors. This output will not be structified.required | defaulted | asOption | asDefaultedOption) is used to determine how to handle whether the field key is there, and schema defines the schema to match for the field's value. In the output object, newKey will be used as the field name. Note, this method has many convenience methods defined such as FieldSchema.required('key').FAQs
Basic javascript object validation
We found that @ephox/boulder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.