1.0.22 • Published 2 years ago

snparse v1.0.22

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

SNParse

Permite filtrar objetos de la misma forma que se hace en las plantillas de Mongoose.

example

import {Parse, VType, PModelAttributes} from "snparse";

const getActivos = async (activoName: string, args:{
    page?: number,
    size?: number,
    q?: string,
    test1?: string,
    test2?: string,
    test3?: string,
  } = {})=>{
    activoName = Parse.Alone(activoName, { type: VType.String });
    const { 
        page, size, q, test1, test2, test3 
    } = Parse.Validate(args, {
      page: {type: VType.Number, default: 0, min: 0},
      size: {type: VType.Number, default: 25, min: 5, max: 9999 },
      q: {type: VType.Number, min: 0},
      test1: {type: VType.String, required: true, regex: /abc/},
      test2: {type: VType.Boolean, default: true, one: "required_one"},
      test3: {type: VType.String, enum: ["m","f"], one: "required_one"},
    } as PModelAttributes<typeof args>)
    console.log("Variables OK", activoName, page, size, q, test1, test2, test3);
}

install

With npm do:

npm install snparse

license

MIT

1.0.22

2 years ago

1.0.21

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago