How to set a Password Policy for Apple OS X or macOS

An administrator can define a local password policy, such as requiring a minimum number of characters in Apple OS X.
If you manage multiple Apple devices, consider contacting ITS about desktop management for Apple devices. See http://software.sites.unc.edu/desktop-management/

The current password policy for UNC-CH can be found at:
http://its.unc.edu/about-us/how-we-operate/

See the references at the bottom for a few good examples on how to set this policy on a device.

Below is a sample XML policy to require passwords be at least 8 characters in length.

minchars.plist

<dict>
   <key>policyCategoryPasswordContent</key>
   <array>
      <dict>
         <key>policyContent</key>
         <string>policyAttributePassword matches '.{8,}+'</string>
         <key>policyIdentifier</key>
         <string>com.apple.policy.legacy.minChars</string>
         <key>policyParameters</key>
         <dict>
            <key>minimumLength</key>
            <integer>8</integer>
         </dict>
      </dict>
   </array>
<dict>

To set the requirement, navigate to Utilities and open the Terminal app as an administrator .
Run the command:

pwpolicy -setaccountpolicies [filename]

where [filename] is minchars.plist in this example

References:
Example on Configuring a Password Policy
https://www.jamf.com/jamf-nation/discussions/18574/user-password-policies-on-non-ad-machines
Manual page for pwpolicy
http://rustyisageek.blogspot.com/2014/11/playing-with-pwpolicy.html