Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@commodo/fields
Advanced tools
Creates a new function, whose instances are decorated with defined fields and additional methods.
Creates a new function, whose instances are decorated with defined fields and additional methods.
import { withFields, string, number, boolean, fields } from "@commodo/fields";
import { compose } from "ramda";
const User = compose(
withFields({
email: string(),
previousEmails: string({ list: true }),
age: number({
validation: value => {
if (value < 30) {
throw Error("User too young.")
}
}
}),
verified: boolean(),
company: fields({ instanceOf: Company })
})
)(function() {});
const Company = compose(
withFields({
name: string()
})
)(function() {});
const user = new User();
user.populate({
email: "user3@email.com",
previousEmails: ["user2@email.com", "user1@email.com"],
age: 25,
verified: true,
company: {
name: "Awesome Company"
}
});
// Throws an error with message "User too young".
async user.validate();
withFields(fields : { [string] : FieldFactory }): WithFieldsFunction
Creates a new function, whose instances contain defined fields and are decorated with populate
and validate
methods.
WithFieldsFunction
Except fields, instances of WithFieldsFunction
are decorated with a couple of useful methods.
populate(data: Object): void
Populates fields with given data.
validate(): Promise<void>
Validates all fields.
getFields(): Array<Field>
Returns all fields.
getField(name: string): ?Field
Returns a single field.
clean(): void
Sets instance as clean.
isDirty(): boolean
Checks if instance is dirty.
FAQs
Enables defining rich data models by decorating function instances with specified model fields. Additionally, it adds `populate` and `validate` methods, for populating model instances with data, and then validating it, respectively.
The npm package @commodo/fields receives a total of 844 weekly downloads. As such, @commodo/fields popularity was classified as not popular.
We found that @commodo/fields demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.