ajv-keywords icon indicating copy to clipboard operation
ajv-keywords copied to clipboard

`transform` Addtions (WIP)

Open willfarrell opened this issue 7 years ago • 4 comments
trafficstars

Just jotting down notes for after https://github.com/epoberezkin/ajv-keywords/pull/64 is merged

  • [ ] Allow options, similar to dynamicDefaults

  • [ ] toEnumCase have option to ignore certain char when determining uniqueness ie strip out , and -

  • [ ] replace string or regex

  • [ ] strip html tags w/ options (alias of replace w/ defaults)

  • [ ] review idea of having addons for more complex/custom transforms

    • [ ] xss
  • [ ] leftPad/rightPad/regexPad/patternCoerce string. ie 1:45 -> 01:45:00.000

  • [ ] floor/ceil number

Options: (WIP)

{
  "type":"object",
  "transforms":{
    "$defaults":{
    },
    "name":{
      "toEnumCase":{"ignorePattern":"[\.]", "ignore":[",","-"]}
    },
    "time":{
      
    }
  }
}

Ref: https://github.com/epoberezkin/ajv-keywords/pull/64

willfarrell avatar Apr 23 '18 16:04 willfarrell

Instead of trying to include all the cases for the possible needed transform see if it's possible to have the transform keyword take a custom function

{
transform:['trim', (x) => x+'string']
}

khaledosama999 avatar Feb 23 '21 15:02 khaledosama999

@khaledosama999 having javascript inside of json will break other things (linter for example). ajv v7 has some new abilities that allow #99 to be more possible. I can see the transform keyword disappearing at some point in favour of a collection of custom keywords that can do the transform.

willfarrell avatar Feb 23 '21 15:02 willfarrell

So right now what is the solution? I want to encode incoming URLs that include spaces so is there any way to do that right now ?

khaledosama999 avatar Feb 23 '21 15:02 khaledosama999

There isn't a solution right now that I'm aware of.

willfarrell avatar Feb 23 '21 17:02 willfarrell