![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
awesomize
Advanced tools
Totally Awesome Validation/Sanitization/Normalization for your app.
npm install awesomize
Awesomize
First, require the module.
const Awesomize = require 'awesomize'
Then, build your awesomizer function.
// Example inputs
const vals = {
foo: 'foo'
, bar: 'bar'
};
// Your validator spec
const spec = Awesomize({}, (v) => {
return {
foo: {
validate: [ v.required ]
}
, bar: {
validate: [ v.required ]
}
}
});
This will return a function that you pass your object of values to, which then in turn returns a promise.
The function given to the Awesomizer will map to the values in the object that it is given. Each validate key is a list, and multiple validation functions can be provided. Each will be run on the associated values. If a key is not explicitly required, then it is optional.
In addition to simple validation, Awesomize allows you to add sanitization and normalization. Sanitization occurs before checking validation, and normalization occurs after. Here we'll use Ramda for some example functions.
const _ = require 'ramda'
const spec = Awesomize({}, (v) => {
return {
foo: {
// Sanitize -> validate -> normalize
sanitize: [ _.toLower ]
, validate: [ v.required ]
, normalize: [ _.toUpper ]
}
}
})
Awesomize.dataOrError
Awesomize.dataOrError
works similarly to Awesomize
, but allows you to pass an error function before the validation function. With this function, in the event that any of the validation fails, it throws the provided error function.
const spec = Awesomize.dataOrError(errorFn)({}, (v) => {
return {
// validators
...
}
});
read
When included along-side validation, read
allows you to form more complex information for the validator to check. the functions in read
have access to the entire object passed to the Awesomize function.
const _ = require 'ramda'
// gets the value at req.bar.baz and adds 1 to it.
const addOneToPath = _.compose(
_.inc
, _.path(['bar', 'baz'])
);
const isTwo = (val) => { val === 2 };
const spec = Awesomize({}, (v) => {
return {
foo: {
read: [ addOneToPath ]
, validate: [ isTwo ]
}
}
});
The following validation functions are built-in:
// required
v.required
// not equal to (x)
v.notEqual(x)
// is array
v.isArray
// is function
v.isFunction
// is a list of (checkFn)
// Takes a function that returns a boolean and an optional message
v.listOf({(a) -> bool}, msg)
Awesomize.Result.hasError
on a result set to see if any of them failed validation.null
on successful validation, or a string on failed validation.FAQs
Totally Awesome Validation/Sanitization/Normalization for your app.
The npm package awesomize receives a total of 10 weekly downloads. As such, awesomize popularity was classified as not popular.
We found that awesomize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.