Giter Site home page Giter Site logo

Comments (6)

Windos avatar Windos commented on August 23, 2024 1

Personally, I would vote fail (which validate count will do). That'd give me output saying "hey fool, you can only give me 100 of these" then I know I have to batch them in the code on my end.

from bluebirdps.

thedavecarroll avatar thedavecarroll commented on August 23, 2024

On a few of the functions, I was using the private function New-ValidationErrorRecord to generate a cleaner error record when the provided parameters were not valid. I believe this private function was created after Get-TwitterFollowers.

Parameter validation is definitely something that needs to be addressed.

Here is where some confusion creeps in:

Get-TwitterFollowers connects to the following two endpoints. The maximum and default ResultsPerPage for each endpoint is different.

Endpoint ResultsPerPage Max ResultsPerPage Default
followers/list.json 200 50
followers/ids.json 5000 5000

I'll need to see how to implement the two defaults and maximum values within a ValidateScript. Since the endpoint is determined by the ParameterSetName, I'm not sure if I can use that in a ValidateScript.

I've asked Twitter. Hopefully, someone can provide some insight.

Thanks

from bluebirdps.

thedavecarroll avatar thedavecarroll commented on August 23, 2024

Additionally, there are some parameters that can accept an array, but the array cannot exceed a certain count.

During the ValidateScript, the count of the array is not available.

Instead of returning with a warning, which is the current behavior, we could simply warn that anything over the maximum count will be truncated. This would need to be handled within the body of the function.

Get-TwitterFriendship -ScreenName $Names
WARNING: More than 100 ScreenNames provided. Processing the first 100 only.

from bluebirdps.

Windos avatar Windos commented on August 23, 2024

For those array ones, remember that you can include multiple validation options:

param (
    [ValidateCount(1,3)] # Needs at least object, but can include up to three
    [ValidateNotNullOrEmpty()]
    [ValidateScript({Test-Item $_})]
    [string[]] $Name
)

As a user I'd prefer to be told upfront if I've included an array that's too long, and I should go and fix my code to break it up (as having the cmdlet truncate the array for me could be iffy when I try to figure out "ok... which ones do I need to re do?")

from bluebirdps.

thedavecarroll avatar thedavecarroll commented on August 23, 2024

Wowzers! [ValidateCount()] satisfies UserId and ScreenName quite nicely!

So, the question would be: terminating failure over 100 OR warning over 100?

What do you think @Windos ?

from bluebirdps.

RobinDadswell avatar RobinDadswell commented on August 23, 2024

I would also vote for fail (by using validate count) as it makes it more clear that something is wrong as opposed to not getting all the data and potentially not seeing the yellow warning

from bluebirdps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.