Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
git.sr.ht/~jackmordaunt/gio-planet/form
Primitives for specifying forms.
The fundamental idea explored here is in separating form concerns.
The three core abstractions are the Form
, the Value
and the Input
.
Value
and Input
combine together into a Field
.
Input
abstracts the interactible graphical widget that accepts input.Value
abstracts the transformation of text to structured data.Field
maps an Input
to a Value
.Form
provides a consistent api for handling a group of fields, namely batch and realtime validation.This repo is experimental, and does not have a stable interface.
Ideally form initialization would be fully declarative, where the zero value is directly usable. However it's not clear how to achieve such an api.
Some potential avenues to explore:
form.Field
s on the fly.Since the api is experimental, there is no "idiomatic usage".
Fundamentally, a form binds inputs to values and there are numerous ways to compose it.
This is an example of one way to use the package: one-time initialization that you can call in an update function once per frame.
type Person struct {
Age int
Name string
Salary float64
}
type PersonForm struct {
form.Form
// Model contains the structured data.
Model Person
// Inputs contains the input state.
Inputs struct {
Age component.TextField
Name component.TextField
Salary component.TextField
}
init sync.Once
}
func (pf *PersonForm) Update() {
pf.init.Do(func() {
pf.Form.Load([]form.Field{
{
Value: value.Int{Value: &pf.Model.Age, Default: 18},
Input: &pf.Inputs.Age,
},
{
Value: value.Required{value.Text{Value: &pf.Model.Name, Default: ""}},
Input: &pf.Inputs.Name,
},
{
Value: value.Float{Value: &pf.Model.Salary, Default: 0},
Input: &pf.Inputs.Salary,
},
})
})
}
FAQs
Unknown package
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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.