Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

yup validation typescript

// install yup
// npm install -S yup

// import yup
import * as yup from yup;

// prepare a schema
let schema = yup.object().shape({
  name: yup.string().required(),
  age: yup.number().required().positive().integer(),
  email: yup.string().email()
});

// validate any object
schema
  .isValid({
    name: 'jimmy',
    age: 24,
  })
  .then(function (valid) {
    valid; // => true
  });
 
PREVIOUS NEXT
Tagged: #yup #validation #typescript
ADD COMMENT
Topic
Name
6+3 =