mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Added safety check on getValidated
This commit is contained in:
@@ -502,6 +502,12 @@ export function isValid(opts: any, schemaName: Schema): boolean {
|
|||||||
|
|
||||||
export function getValidated<T extends Object>(opts: any, schemaName: Schema): T {
|
export function getValidated<T extends Object>(opts: any, schemaName: Schema): T {
|
||||||
const resolvedSchema = resolveSchemaName(schemaName);
|
const resolvedSchema = resolveSchemaName(schemaName);
|
||||||
|
|
||||||
|
if (!resolvedSchema) {
|
||||||
|
schemaDebug(`validation failed due to missing or mispelled schema name`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const validation = resolvedSchema.validate(opts, { stripUnknown: true });
|
const validation = resolvedSchema.validate(opts, { stripUnknown: true });
|
||||||
|
|
||||||
if (validation.error) {
|
if (validation.error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user