本文整理汇总了TypeScript中express-validator/check.check函数的典型用法代码示例。如果您正苦于以下问题:TypeScript check函数的具体用法?TypeScript check怎么用?TypeScript check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: check
getOrderWithDetails,
updateOrder
} from '../data/orders';
import { getAllProducts } from '../data/products';
import { getAllRegions } from '../data/regions';
import { getAllShippers } from '../data/shippers';
const router = express.Router();
/**
* A set of validations to apply for the "create order" (POST /order) request.
* These ensure that informative error messages are generated in the event that
* any required properties are missing, they're of the wrong types, etc...
*/
const CREATE_ORDER_VALIDATIONS = [
check('employeeid')
.exists()
.isNumeric()
.toInt(),
check('customerid')
.exists()
.isAlphanumeric()
.trim(),
check('shipcity')
.exists()
.trim(),
check('shipaddress')
.exists()
.trim(),
check('shipname')
.exists()
示例2: async
router.get('/', async (req, res, next) => {
try {
let { filter = '' } = req.query || {};
let customers = await getAllCustomers({ filter }); // * get the data
res.render('customers', { customers, filter });
} catch (e) {
next(e);
}
});
/**
* Handle the HTTP request an individual Customer
*/
router.get(
'/:id',
[check('id')],
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
try {
let { page = 1, perPage = 30, sort, order } = req.query;
let id = req.params.id;
let customer = await getCustomer(id); // * get the data
let orders = await getCustomerOrders(id, { page, perPage, sort, order }); // * get the data
res.render('customers/show', { customer, orders, page });
} catch (e) {
next(e);
}
}
);
export default router;
示例3: timeline
private timeline() {
this.router.get('/timeline', [check(['range', 'start', 'end'])],
EndpointController.timeline.bind(EndpointController));
}
示例4: index
private index() {
this.router.get('/', [check(['range', 'start', 'end'])],
EndpointController.all.bind(EndpointController));
}
示例5: projects
private projects() {
this.router.get('/projects', [check(['range', 'start', 'end'])],
EndpointController.projects.bind(EndpointController));
}
示例6: languages
private languages() {
this.router.get('/languages', [check(['range', 'start', 'end'])],
EndpointController.languages.bind(EndpointController));
}
示例7: editors
private editors() {
this.router.get('/editors', [check(['range', 'start', 'end'])],
EndpointController.editors.bind(EndpointController));
}
示例8: switch
};
export const isImage = (path: string): boolean => {
const position = path.lastIndexOf('.');
if (position < 1) { return false; }
switch (path.slice(position + 1).toLowerCase()) {
case 'jpg': return true;
case 'jpeg': return true;
case 'png': return true;
case 'tiff': return true;
default: return false;
}
};
export const vInitiateXEMPurchase = [
check(KEY_PRODUCT_ID)
.exists()
.trim()
.custom(validateProduct),
check(KEY_TOKEN_RECIPIENT_ADDRESS)
.exists()
.trim()
.custom(validateTokenAddress)
.withMessage(`${DATA_ERR_BY.MISSING_PARAMS}: ${KEY_TOKEN_RECIPIENT_ADDRESS}`),
check(KEY_TOKEN_TYPE)
.exists()
.trim()
.custom(validateTokenType),
errorHandler
];
示例9: check
inventory: 'needs-reorder' | 'discontinued';
requiredTags: string[];
flavor: ProductFlavorFilter[];
}
import {
getAllProducts,
getProduct,
getProductPricingHistory,
updateProduct
} from '../data/products';
const router = express.Router();
const ALL_PRODUCTS_VALIDATORS = [
check('flav').isWhitelisted(['sweet-hot', 'refreshing', 'sweet-sour']),
check('inventory').isLowercase(),
check('tags').isLowercase()
];
const UPDATE_PRODUCT_VALIDATORS = [
check('metadata.flavor.sweet')
.exists()
.isNumeric()
.toInt(),
check('metadata.flavor.salty')
.exists()
.isNumeric()
.toInt(),
check('metadata.flavor.spicy')
.exists()